HI. I just want to ask if anyone can provide me an example of connection string.
Im using VS 2003 and i want to connect to MS SQL.. Thanks
Printable View
HI. I just want to ask if anyone can provide me an example of connection string.
Im using VS 2003 and i want to connect to MS SQL.. Thanks
Thanks for the source... it has many choices but i still need the proper coding... Im Using VS 2003 and connecting to MS SQL.
Code:
Dim connection As New SqlClient.SqlConnection("connection string")
Dim command As New SqlClient.SqlCommand("SELECT * from test_ezon", connection)
connection.Open()
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()
While reader.Read()
MessageBox.Show(String.Format("There are {0} {1} remaining in stock.", _
reader("Quantity"), _
reader("Name")))
End While
reader.Close()
connection.Close()
You asked for the appropriate connection string format for SQL Server and that site provides it. The question you asked has been answered. What exactly is the problem? Are you asking, without actually asking, for more than just a connection string?
Actually I'm having this problems..
having this codes... im having this error msg...Code:Dim dBase As String
dBase = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=TSI-CWISTIAN;"
Dim connection As New SqlClient.SqlConnection(dBase)
Dim command As New SqlClient.SqlCommand("SELECT * from test_ezon", connection)
Code:An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: Keyword not supported: 'provider
If you don't follow the right links then you're not going to get the right information. You're using a SqlConnection to connect to SQL Server and you're using an OLEDB connection string for SQL Server Compact Edition. Let's read that page I linked to. It provides links to connection strings for SQL Server 2008, SQL Server 2005, SQL Server 2000/7.0. I'm not sure why you arbitrarily decided to follow the CE link when you're not using CE. Follow the right link and then take a connection string from the right section.
Im not really famillar with the choices.. i use the
Quote:
SqlConnection (.NET)
Standard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
now my problem is if im using the right code... kinldly pls check my codes./..Code:Dim dBase As String
dBase = "Data Source=TSI-CWISTIAN;Initial Catalog=test_ezon;Integrated Security=SSPI;"
Dim connection As New SqlClient.SqlConnection(dBase)
Dim command As New SqlClient.SqlCommand("SELECT * from test_ezon", connection)
connection.Open()
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()
While reader.Read()
MessageBox.Show(String.Format("There are {0} {1} remaining in stock.", _
reader("Quantity"), _
reader("Name")))
End While
reader.Close()
connection.Close()
i having problem with this line
i just use the one you posted at databank...Quote:
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()
Code:1.
Dim connection As New SqlConnection("connection string here")
2.
Dim command As New SqlCommand("SELECT Quantity, Unit, Name FROM StockItem", connection)
3.
4.
connection.Open()
5.
6.
Dim reader As SqlDataReader = command.ExecuteReader()
7.
8.
While reader.Read()
9.
MessageBox.Show(String.Format("There are {0} {1} of {2} remaining in stock.", _
10.
reader("Quantity"), _
11.
reader("Unit"), _
12.
reader("Name")))
13.
End While
14.
15.
reader.Close()
16.
connection.Close()
That's my CodeBank thread and I provided the very same link to ConnectionStrings.com in that thread. Beginner or not, you should be able to read what the different databases are that they provide examples for and follow the appropriate link, then read through that page and make an attempt at deciding which is the appropriate one.
Now, you're on the right page and you're in the right section so that's good. That connections string means you're logging onto an unnamed instance of SQL Server as the current Windows user on a machine named TSI-CWISTIAN and opening a database named test_ezon. Is that what you want to do? If so then it's correct. Did it work when you tried it? If so then that would also suggest that it's correct. If it didn't work then maybe it's not correct.