vmandem
asked on
Hi how do I connect to my sqlserver database from VB.NET
I'm using the connection string like this:
Dim strconnection = "Server=local;Database=VM; User ID=sa;Password=hello;Trust ed_Connect ion=False"
and this is the code I'm using to open the connection
Dim oSQLConn As SqlConnection = New SqlConnection
oSQLConn.ConnectionString = strconnection
oSQLConn.Open()
But I get the error like this:
An unhandled exception of type 'System.Data.SqlClient.Sql Exception' occurred in system.data.dll
Additional information: System error.
What could be the problem. I checked the sqlserver and I set the username and password for the VM database as
"sa" and "hello"
Thanks
vm
Dim strconnection = "Server=local;Database=VM;
and this is the code I'm using to open the connection
Dim oSQLConn As SqlConnection = New SqlConnection
oSQLConn.ConnectionString = strconnection
oSQLConn.Open()
But I get the error like this:
An unhandled exception of type 'System.Data.SqlClient.Sql
Additional information: System error.
What could be the problem. I checked the sqlserver and I set the username and password for the VM database as
"sa" and "hello"
Thanks
vm
ASKER
TheLearnedOne
I got connected to the sqlserver and I changed the server name and it worked. Can you please tell me how to retreive data from the sql query to a recordset and I want to pass the recordset value to a textbox.
Thanks and appreciate your help.
vm
I got connected to the sqlserver and I changed the server name and it worked. Can you please tell me how to retreive data from the sql query to a recordset and I want to pass the recordset value to a textbox.
Thanks and appreciate your help.
vm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to fill in the holes:
Dim connectionSQL As SqlConnection = New SqlConnection(connectionSt ring)
conn.Open()
Dim commandGetData As SqlCommand = New SqlCommand(queryString, connectionSQL)
Me.TextBox1.DataBindings.A dd(New Binding("Text", DataSet1, "Table.Field"))
Bob
Dim connectionSQL As SqlConnection = New SqlConnection(connectionSt
conn.Open()
Dim commandGetData As SqlCommand = New SqlCommand(queryString, connectionSQL)
Me.TextBox1.DataBindings.A
Bob
Right at the same time!!!
Bob
Bob
Bob