By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

How to set connection string in

P: 13
Hi, i would like to know how should i set my connection string in

In my VB6 code, this is how i set my connection string:

conDetail.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\FCC\Desktop\\SapWVA\Data\100\ WVAdvert.MDB;Persist Security Info=False;"

My question here is, how do i do the same thing in

Please help.
Many thanks.
Apr 27 '07 #1
Share this Question
Share on Google+
1 Reply

P: 37

Connecting to a DataSource using SqlClient Connection String in vb 2005

There are two ways.

Dim strConnect As String=”Data Source=localhost;Initial Catalog=pubs;Integrated Security=SSPI;”
Dim myConnection As SqlConnection=New SqlConnection(strConnect)

In the above code, we are taking advantage of the SqlConnection object’s parameterized constructor to set the ConnectionString property directlty, at the same time as it is instantiated.

Another option is:

Dim myConnection As SqlConnection=New SqlConnection()
myConnection.ConnectionString=”DataSource=localhos t;Initial Catalog=pubs;Integrated Security=SSPI;”

Data source – Machine Name
InitialCatalog – Name of the Database
Integrated Security – This indicates that the current user’s Windows Credentials are being used to access SQL Server.

Note: Connection strings require exact syntax, including spacing and case sensitivity in some cases. Visual Studio.Net tools that will help to create connection strings.

Here is an example of a connection string for a Microsoft Access database.

Dim myConn As OleDbConnection=New OleDbConnection()
"Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
"Source=C:\data\northwind.mdb;User ID=guest; " &_

[Link Removed]
Apr 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.