sql connection string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello again,

Can anyone tell me the correct connection string to use? My database is on
the E: drive of a remote server. I can either map a drive from my local
machine to it, or use the \\servername\ stuff.

I can't seem to get it right.

thanks,
Art
 
I suppose you are using MS Access?

There's an easy way to create a connectionstring:
- Create a new textfile
- Rename it from 'New Text Document.txt' to 'Connection.udl' (the name
doesn' matter, the extension is the important part)
- Doubleclick on this file
- On the first tab (Provider) select 'Microsoft Jet 4.0 OLE DB Provider'
- Click the 'Next' button
- Browse to the database and select it
- Press the 'Test Connection' button, this should succeed
- Close the wizard
- Open the UDL file with notepad
- The last line is the connectionstring to use

Good luck!
 
Ken,

Can I do this with sql server? I'm not at work right now and can't test it
out till tomorrow. If this works with sql server it sounds great!

Art
 
Sahil,

Thanks for the response. I did go to connectionstrings. The problem that I
think I'm having is how to refer to the remote server, something that I
didn't get from connectionstrings.

Art
 
You can use the same method for every provider on your system (Oracle, SQL
Server, Access, Excel, ...)

- Select the provider for SQL Server
- Press the 'Next' button
- Enter the servername (*1)
- Specify username and password
- Check 'Allow saving password' (Select 'Yes' to the security warning when
pressing the OK button when finished)
- Select the database
- Test the connection


If you are using SQL Server you will be using the SQLClient, so remove the
Provider-part of the connectionstring

Provider=SQLOLEDB.1;Password=123;Persist Security Info=True;User
ID=sa;Initial Catalog=MyDatabase;Data Source=MyServer

should be

Password=123;Persist Security Info=True;User ID=sa;Initial
Catalog=MyDatabase;Data Source=MyServer


(*1) I'm a little bit confused because you told in your post your database
was on the E: drive of a remote server. That's why I thought you were using
Access.
For SQL Server it doesn't matter on what drive the database resides, you
should be able to connect using the servername...
 
Art,

If you have a database as MS-Access file than your DataBase is accessable
with its file name.

If you have a databaseserver as SQLServer than the database is accessable by
its servername or IP address.

This is a major difference between using (connecting to) databases.

This page probably is referenced the most times in these dotNet newsgroups

http://www.connectionstrings.com/

However, there is as well the very good

http://www.carlprothman.net/Default.aspx?tabid=81

I hope this helps a little bit?

Cor
 
in addition to Cor`s comment

it is still possible to dynamicly load a sql server database file

even better i once released an app that read a sql server database from a
DVD even that is possible


just as with an MDB database file, when you are using the file-based
approach you can include a path to the physical file in the connection
string for the new AttachDBFileName parameter:
Dim ConnStr as string = "Data Source=.\SQLExpress; Initial Catalog=;
Integrated Security=true; AttachDBFileName="X:\MyDb.mdf "

Connecting with this connection string causes the file MyDb.mdf to be
automatically attached to the SQLExpress instance. When the application
ends, it will automatically be detached and therefore not locked and
available for copying.



ps. my favorite refernce is

http://www.carlprothman.net however i liked his website more in the
able-consulting days ( looked nicer to me )



regards



Michel Posseth [MCP]
 
Michael,

Thanks for additional information.

Art

m.posseth said:
in addition to Cor`s comment

it is still possible to dynamicly load a sql server database file

even better i once released an app that read a sql server database from a
DVD even that is possible


just as with an MDB database file, when you are using the file-based
approach you can include a path to the physical file in the connection
string for the new AttachDBFileName parameter:
Dim ConnStr as string = "Data Source=.\SQLExpress; Initial Catalog=;
Integrated Security=true; AttachDBFileName="X:\MyDb.mdf "

Connecting with this connection string causes the file MyDb.mdf to be
automatically attached to the SQLExpress instance. When the application
ends, it will automatically be detached and therefore not locked and
available for copying.



ps. my favorite refernce is

http://www.carlprothman.net however i liked his website more in the
able-consulting days ( looked nicer to me )



regards



Michel Posseth [MCP]



Cor Ligthert said:
Art,

If you have a database as MS-Access file than your DataBase is accessable
with its file name.

If you have a databaseserver as SQLServer than the database is accessable
by its servername or IP address.

This is a major difference between using (connecting to) databases.

This page probably is referenced the most times in these dotNet newsgroups

http://www.connectionstrings.com/

However, there is as well the very good

http://www.carlprothman.net/Default.aspx?tabid=81

I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top