Friday, December 28, 2012

What is difference between unique key and primary key?


There is two difference between them.
1. The not null constraint is by default added to primary key, it means, primary key attribute cannot accept null values, whereas, the attribute declared as unique can accept null values. It is the major difference between the two.
2. Secondly, we can have only one primary key in a relation, whereas, multiple attributes can be declared unique at the same time.

Friday, December 7, 2012

Binding Checked List box control with data


        CheckedListAccount.DataSource = Dset.Tables(0) ' Dataset containing datatable

        CheckedListAccount.DisplayMember = "account_name" 'display field
        CheckedListAccount.ValueMember = "account_id"        'id filed

'to get selected items id from checked list box


        For Each checkeditem As DataRowView In CheckedListAccount.CheckedItems
            MsgBox(checkeditem.Item("account_id").ToString())
        Next


Thursday, October 4, 2012

In SQL, what are the differences between primary, foreign, and unique keys?

In SQL, what are the differences between primary, foreign, and unique keys?

 
Both primary and unique keys can span multiple columns within a table. Two differences exist:
1. A table may have more than one unique key. This depends on the design of the table. But, a table can have only one primary key.
2. The values in the unique key columns may or may not be NULL. The values in primary key columns, however, can not be NULL.
While unique and primary keys both enforce uniqueness on the columns of one table, foreign keys define a relationship between 2 tables. A foreign key identifies a column or group of columns in one (referencing) table that refers to a column or group of columns in another (referenced) table.
Both unique and primary keys can be referenced by foreign keys.

Wednesday, October 3, 2012

What is the difference between SMALLDATETIME and DATETIME?


"What's that", you ask? You never heard of this SmallDateTime data type?

That does not change the fact that it does indeed exist. And yes, even your SQL Server 2000 has it!

Here are the main differences you should know about these two datetime types:

1. Range of Dates

A DateTime can range from January 1, 1753 to December 31, 9999.
A SmallDateTime can range from January 1, 1900 to June 6, 2079.

2. Accuracy

DateTime is accurate to three-hundredths of a second.
SmallDateTime is accurate to one minute.

3. Size

DateTime takes up 8 bytes of storage space.
SmallDateTime takes up 4 bytes of storage space.


Armed with this knowledge, you may want to use SmallDateTime instead of DateTime if you only need to represent dates from January 1, 1900 to June 6, 2079 and you do not need accuracy below 1 minute. Why? Simple! Using SmallDateTime will reduce the amount of data your queries are pulling back. The size of each row will be a bit smaller.


That's it for now... be sure to check back soon for more information on using datetime in SQL Server.

Friday, July 13, 2012

Search column name in tables in SQL Database


select
sc.name as col_name,so.name as table_name from syscolumns sc inner join sysobjects so on so.id=sc.id where sc.name like 'column_name' and so.xtype='U'

Tuesday, July 3, 2012

Save VsFlexGrid data to excel


  1. Private Sub FlexToExcel()
  2. Dim xlObject    As Excel.Application
  3. Dim xlWB        As Excel.Workbook
  4.        
  5.     Set xlObject = New Excel.Application
  6.     'This Adds a new woorkbook, you could open the workbook from file also
  7.     Set xlWB = xlObject.Workbooks.Add
  8.                
  9.     Clipboard.Clear 'Clear the Clipboard
  10.     With MSFlexGrid1
  11.         'Select Full Contents (You could also select partial content)
  12.         .Col = 0               'From first column
  13.         .Row = 0               'From first Row (header)
  14.         .ColSel = .Cols - 1    'Select all columns
  15.         .RowSel = .Rows - 1    'Select all rows
  16.         Clipboard.SetText .Clip 'Send to Clipboard
  17.     End With
  18.            
  19.     With xlObject.ActiveWorkbook.ActiveSheet
  20.         .Range("A1").Select 'Select Cell A1 (will paste from here, to different cells)
  21.         .Paste              'Paste clipboard contents
  22.     End With
  23.    
  24.     ' This makes Excel visible
  25.     xlObject.Visible = True
  26. End Sub

Monday, July 2, 2012

Binding Combobox at run time without using database connection via Dictionery Objec

        Dim objDict As New Dictionary(Of String, String)
        objDict.Add("1", "Value 1")
        objDict.Add("2", "Value 2")


        ComboBox1.DataSource = New BindingSource(objDict, Nothing)
        ComboBox1.DisplayMember = "Value"
        ComboBox1.ValueMember = "Key"

Saturday, June 30, 2012

Difference between Panel and GroupBox classes in .NET

The both classes that is Panel and GroupBox can be used as a container for other controls such as check box control, radio button control etc. But the difference between these two classes is 
• In case of Panel class captions cannot be displayed i.e. we can’t set caption but in GroupBox class captions can be displayed. 
• The Panel class can have scroll bars but GroupBox class cannot have scroll bar.

Thursday, June 28, 2012

Add row to bound Datagrideview


        Dim dr As DataRow = CType(DgviewDetail.DataSource, DataTable).NewRow
        dr.Item(1) = "anand"

        'DgviewDetail.Rows.Add(dr)

        CType(DgviewDetail.DataSource, DataTable).Rows.Add(dr)

Wednesday, June 13, 2012

excel connection string



ExcelCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + WorkBook + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';")

Monday, May 7, 2012

to set database owner

use databasename

sp_changedbowner

user_name

Monday, April 30, 2012


access connection string with password and without password
  
    If DbPass.Length > 0 Then
            AccCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database password=" & DbPass & ";Data Source=" & Dpath & "")
        Else
            AccCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Dpath & "")
        End If

Saturday, April 28, 2012

Tech

if you want to re install visual studio on your pc then use control panel add/remove option