SQL Data Base Connection code
By karthick
,
0 Comments
Imports System
Imports
System.Web.UI.WebControls
Imports
System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Dim myConnection As
System.Data.SqlClient.SqlConnection
Dim myCommand As System.Data.SqlClient.SqlCommand
Dim strSQL As String
myConnection = New SqlConnection("Data
Source=MCANODE-102\MCA;Initial Catalog=master;Integrated Security=True")’master is database name,MCANODE_102\MCA
hostname
myConnection.Open()’Open the connection
strSQL = "SELECT * FROM kar where id=12" ‘kar is tablename,id is field
myCommand = New
SqlCommand(strSQL, myConnection)
Dim
re As SqlDataReader = myCommand.ExecuteReader()
While
re.Read
TextBox1.Text =
re.GetString(2).ToString
End While
myConnection.Close()’Close the connection
0 Response to "SQL Data Base Connection code"
Post a Comment