Thursday, October 16, 2008

Sql Server 2005 Connection Code using VB.NET

Imports system.data.sqlclient
Public class Form1
dim con as new sqlconnection
dim cmd as new sqlcommand
dim dr as new datareader

public sub Button1_click()
Try
con = new sqlconnection("Type ur Connection String")
con.open()
cmd = new sqlcommand("Insert into table1 values ('" & TextBox1.Text &"','" & TextBox2.Text"')",con)
i=cmd.ExecuteNonquery()
msgbox("Record Inserted ",i)
Catch ex as Exception
End Try
con.open()
End Sub

No comments: