PC_tech22
asked on
Can't connection to SQL Server Database System.Data.SqlClient.SqlException was unhandled
I am just trying to connect to Northwind and Pubs
Dim myConnection As New SqlConnection("Database=Pu bs;Server= (local);UI D=sa;PWD=; ")
Dim myCommand As New SqlCommand
myConnection.Open()
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.Text
myCommand.CommandText = "select * from titles"
Dim daEmp As New SqlDataAdapter(myCommand)
Dim dsEmp As New DataSet
daEmp.Fill(dsEmp, "Employees")
gvEmp.DataSource = daEmp
I don't want to be a DBA just a Developer, with full permissions to the data, :( it is holding me back
Thanks
Dim myConnection As New SqlConnection("Database=Pu
Dim myCommand As New SqlCommand
myConnection.Open()
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.Text
myCommand.CommandText = "select * from titles"
Dim daEmp As New SqlDataAdapter(myCommand)
Dim dsEmp As New DataSet
daEmp.Fill(dsEmp, "Employees")
gvEmp.DataSource = daEmp
I don't want to be a DBA just a Developer, with full permissions to the data, :( it is holding me back
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PWD=;"
should be
PWD=";
should be
PWD=";
ASKER
Provider=sqloledb;Data Source=myServerAddress;Ini tial Catalog=myDataBase;User Id=myUsername;Password=myP assword;
What is myServerAddress?
What is myServerAddress?
ASKER
Dim myConnection As New SqlConnection("Initial Catalog=Pubs;Server=(local );UID=sa;P WD=")
This is what I have so far
This is what I have so far
ASKER
Is there something in the SQL Server Manager that I can obtain the connection string?
Thanks for your help.
Thanks for your help.
PC_tech22,
The difference is the try...catch block. It will show the error - whether it's a password issue or not.
The difference is the try...catch block. It will show the error - whether it's a password issue or not.
ASKER
oh ok
Dim myConnection As New SqlConnection("data source=(local); database=Northwind; Trusted_Connection=yes;") '("Initial Catalog=Pubs;Server=(local );UID=sa;P WD=")
Dim myCommand As New SqlCommand
myConnection.Open()
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.Text
myCommand.CommandText = "select * from Employees"
Dim daEmp As New SqlDataAdapter(myCommand)
Dim dsEmp As New DataSet
daEmp.Fill(dsEmp, "Employess")
gvEmp.DataSource = daEmp
It is past the Connection.open problem but does not show in the GridView
Dim myConnection As New SqlConnection("data source=(local); database=Northwind; Trusted_Connection=yes;") '("Initial Catalog=Pubs;Server=(local
Dim myCommand As New SqlCommand
myConnection.Open()
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.Text
myCommand.CommandText = "select * from Employees"
Dim daEmp As New SqlDataAdapter(myCommand)
Dim dsEmp As New DataSet
daEmp.Fill(dsEmp, "Employess")
gvEmp.DataSource = daEmp
It is past the Connection.open problem but does not show in the GridView
ASKER
You may not be able to see it but the old connection string is commented out
ASKER
I also changed to use the NorthWind database
try changing gvEmp.DataSource = daEmp to
gvEmp.DataSource = dsEmp
gvEmp.DataSource = dsEmp
ASKER
It still doesn't work
...and no .databind method
Also I have another Question Open for more points.
...and no .databind method
Also I have another Question Open for more points.
Hi PC_tech22 - you should probably close this question and give points to the experts that helped with your connection problem.
The other question should then give you an answer on how to setup your data bindings. EE states that the max points for any particular question is 500, so I don't want to answer the same question in both :)
Cheers,
Hillwaaa.
The other question should then give you an answer on how to setup your data bindings. EE states that the max points for any particular question is 500, so I don't want to answer the same question in both :)
Cheers,
Hillwaaa.
ASKER
Your're right sorry!:)
Ok other on to other question.
Ok other on to other question.
ASKER
Thank you for your Help with this question.
How exactly did the accepted answer fix the connection problem???
ASKER
I don't see it