|
-
Nov 3rd, 2008, 01:13 AM
#1
Thread Starter
Lively Member
[02/03] Connection String Help
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
-
Nov 3rd, 2008, 01:16 AM
#2
Re: [02/03] Connection String Help
-
Nov 3rd, 2008, 01:22 AM
#3
Thread Starter
Lively Member
Re: [02/03] Connection String Help
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()
-
Nov 3rd, 2008, 01:26 AM
#4
Re: [02/03] Connection String Help
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?
-
Nov 3rd, 2008, 01:29 AM
#5
Thread Starter
Lively Member
Re: [02/03] Connection String Help
Actually I'm having this problems..
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)
having this codes... im having this error msg...
Code:
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: Keyword not supported: 'provider
-
Nov 3rd, 2008, 01:34 AM
#6
Re: [02/03] Connection String Help
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.
-
Nov 3rd, 2008, 02:24 AM
#7
Thread Starter
Lively Member
Re: [02/03] Connection String Help
Im not really famillar with the choices.. i use the
SqlConnection (.NET)
Standard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
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()
now my problem is if im using the right code... kinldly pls check my codes./..
i having problem with this line
Dim reader As SqlClient.SqlDataReader = command.ExecuteReader()
i just use the one you posted at databank...
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()
-
Nov 3rd, 2008, 03:57 AM
#8
Re: [02/03] Connection String Help
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|