How To Connect The Vb.net With Sql
Connection
Collapse
X
-
this link may help you
http://www.aspnettutor ials.com/tutorials/database/connect-sql-datasource-vb.aspx
http://www.freevbcode. com/ShowCode.asp?ID =2226Comment
-
try using this
[code=vb.net]
Dim Cmd As OleDb.OleDbComm and
Dim Con As OleDb.OleDbConn ection
Dim Sql As String = Nothing
Dim Reader As OleDb.OleDbData Reader
Dim ComboRow As Integer = -1
Dim Columns As Integer = 0
Dim Category As String = Nothing
Dim da As System.Data.Ole Db.OleDbDataAda pter
Dim oDS As New System.Data.Dat aSet
Con = New OleDb.OleDbConn ection("Provide r=sqloledb;Data Source=server;I nitial Catalog=databas e;User ID=sa;Password= " & txtserverpasswo rd.Text)
sql = ""
'Run Query
oDS.Clear()
Con.Close()
Cmd = New OleDb.OleDbComm and(Sql, Con)
Con.Open()
da = New OleDbDataAdapte r(Sql, Con)
da.Fill(oDS, "Table2")
DGV.DataSource = oDS.Tables("Tab le2").DefaultVi ew
DGV.Refresh()
ToolStripStatus Label1.Text = "Query Run Successfully"
Catch
ToolStripStatus Label1.Text = "Query Did Not Run Successfully"
End Try
[/code]Comment
Comment