Tech NovoGeek

...Technology Simplified

Thursday, April 26, 2012

Image in Textbox

No comments :
.tb11 {   
    background:#FFFFFF url(search.png) no-repeat 4px 4px;
    padding:4px 4px 4px 22px;
    border:1px solid #CCCCCC;
    width:230px;
    height:18px;
}<div class="tb5">
      <asp:TextBox ID="TextBox1" runat="server" CssClass="tb5a"></asp:TextBox>
  </div>
search

Rounded css textbox

No comments :
 
 
     
     
 
 
    

rounded

Tuesday, April 24, 2012

Location of wsdl.exe

No comments :

C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin

How to split the string based on criteria

No comments :
protected void Button1_Click(object sender, EventArgs e)
{
string k1 = "";
string str = "AAABUS6666666 01 AAAB,INC. 1105070522AAABUS9147930 21 0008060362Smith John 540 N.VIA VALVERDEAAABUS7777777 01 AAAB,INC. 1105070522AAABUS9147930 21 0008060362Carillo Dave 201 Verdugo AveAAABUS8888888 01 AAAB,INC. 1105070522AAABUS9147930 21 0008060362Stevenson Craig 540 N.VIA VALVERDE";
int[] j = new int[500];
for (int i = 0, k=0; i < str.Length; i++,k++)
{
j[k] = str.LastIndexOf("AAABUS");
k1 += str.Substring(j[k], (str.Length - j[k]));
if (k % 2 == 1)
{
k1 += "
" ; } str = str.Substring(0, j[k]); } Response.Write(k1); }

Monday, April 23, 2012

A correlation name must be specified for the bulk rowset in the from clause.

No comments :
While inserting image files into a SQL Server database table using the OPENROWSET function, I got the following error message from the SQL engine. Msg 491, Level 16, State 1, Line 5 A correlation name must be specified for the bulk rowset in the from clause. Here is the t-sql script that is causing the error message :
CREATE TABLE myTable(Document varbinary(max))
INSERT INTO myTable(Document)
SELECT * FROM OPENROWSET(BULK N'D:\DispatchAdvice.png', SINGLE_BLOB)
And the below sql script displays how the correct statement should be built. Take your attention on the "rs" alias name at the end of the script.
CREATE TABLE myTable(Document varbinary(max))
INSERT INTO myTable(Document)
SELECT * FROM OPENROWSET(BULK N'D:\DispatchAdvice.png', SINGLE_BLOB) rs

Friday, April 20, 2012

How to create copy of existing database diagram

No comments :
INSERT INTO sysdiagrams   
([name]
,[principal_id]
,[version]
,[definition])
SELECT 'TESTNAME'
,[principal_id]
,[version]
,[definition]
FROM sysdiagrams
where diagram_id = 6

select * from sysdiagrams

Flashing table row background

No comments :
Can check this helps
http://jsfiddle.net/anuradha/w9UQn/

copy code and line numbers in visual studio 2010

No comments :

There is an addon supported in visual studio to copy syntax highlighting and line numbers .Download it from the link http://copysourceashtml.codeplex.com/
It is version for VS2008 ,you need to make some changes to support VS2010.
Download latest CopySourceAsHtml msi and install it
1.By default it will be installed to C:\Users\<username>\My Documents\Visual Studio 2008\Addins
2.Create a folder named Addins under C:\Users\<username>\My Documents\Visual Studio 2010 and copy CopySourceAsHtml.AddIn here.
3.Modify Line #5 and #9 change <Version>9.0</Version> to<Version>10.0</Version>
4.Launch Visual Studio 2010 –> Tools –> Addin Manager, if you see CopySourceAsHtml shows up, then it’s enabled successfully.

1

6.Now you can select the code and get html by clicking Copy As Html

2

This is an example. CopySourceAsHtml also provides options to show/hide control line number, word wrap and so on.

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace HelloWorld
7 {
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 // My first application
13 System.Console.WriteLine(“Hello, World!”);
14 }
15 }

Printer status in c#

No comments :
Add references for system.management from .Net dlls.
using System.Collections.Specialized; 
using System.Management;
#region GetPrintJobsCollection
        ///  
        /// Returns the jobs in printer queue 
        ///  
        /// Printer Name. 
        /// StringCollection 
        public StringCollection GetPrintJobsCollection(string printerName) 
        { 
            StringCollection printJobCollection = new StringCollection(); 
            try 
            { 
                //Query the printer to get the files waiting to print. 
                string searchQuery = "SELECT * FROM Win32_PrintJob";
                ManagementObjectSearcher searchPrintJobs = new ManagementObjectSearcher(searchQuery); 
                ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();

                foreach (ManagementObject prntJob in prntJobCollection) 
                { 
                    String jobName = prntJob.Properties["Name"].Value.ToString();
                    //Job name would be of the format [Printer name], [Job ID] 
                    char[] splitArr = new char[1]; 
                    splitArr[0] = Convert.ToChar(","); 
                    string prnName = jobName.Split(splitArr)[0]; 
                    string documentName = prntJob.Properties["Document"].Value.ToString(); 
                    if (String.Compare(prnName, printerName, true) == 0) 
                    { 
                        printJobCollection.Add(documentName); 
                    } 
                } 
            } 
            catch (Exception ex) 
            { 
                // Log the exception. 
            } 
            return printJobCollection; 
        }
        #endregion GetPrintJobsCollection
The following code displays all properties for a given printer name. Among them you will find: PrinterStatus, Comment, Location, DriverName, PortName, etc.
string printerName = "YourPrinterName";
string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerName);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection coll = searcher.Get();

foreach (ManagementObject printer in coll)
{
    foreach (PropertyData property in printer.Properties)
    {
        Console.WriteLine(string.Format("{0}: {1}", property.Name, property.Value));
    }
}

Javascript Datetime validation

No comments :
<html xmlns="http://www.w3.org/1999/xhtml">    
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function validate()
        {
            var fromDate = document.getElementById("txtStartdate").value;
            var toDate = document.getElementById("txtEnddate").value;
            if (fromDate == '' || toDate == '')
                {
                   alert("Enter both start and end dates to click search");
                }
            else
                {
                    if (Date.parse(fromDate) > Date.parse(toDate))
                    {
                        alert("Invalid Date Range!\nStart Date cannot be after End Date!")
                        return false;
                    }
                }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" OnClientClick="validate();"
            Text="Button" />
        <asp:TextBox ID="txtStartdate" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtEnddate" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

ASP.Net/C# - Regex Expression

No comments :
var rx = new Regex(@"[^_]+$");
var tests = new string[]
{
"bym338x2101_aev_bk/lasa/a/230862_15",
"bym338x2101_aev_bk/lasa/a/230862_1",
"bym338x2101_aev_bk/lasa/a/230862_103"
};

foreach (var test in tests)
{
Console.WriteLine( rx.Match(test).Value );
}

/* Output

15
1
103

*/

DELETE based on 2 tables

No comments :

select a.*
from temp1 a,
patient b
WHERE a.chart_no = b.chart_no
and b.group_assignment = 'AAA'
How do I delete only records from temp1?

DELETE FROM TEMP1
WHERE CHART_NO IN(
SELECT A.CHART_NO
FROM TEMP1 A,
PATIENT B
WHERE A.CHART_NO = B.CHART_NO
AND B.GROUP_ASSIGNMENT = 'AAA' )

Refresh all tabs at once in Chrome

No comments :

To refresh all the tabs in chrome browser is pretty easier with an Extension.

“Reload All Tabs”

https://chrome.google.com/webstore/detail/midkcinmplflbiflboepnahkboeonkam

Reload all tabs using keyboard shortcut(ctrl + shift + r), context menu, or browser action button.

If you want to remove the browser action button (top right), just right click and choose "Hide button".