-
Jan 20th, 2012, 03:59 PM
#1
Thread Starter
Junior Member
[Resolved] Connection Strings ?
hello everyone,
can some one please explain to me connection string because i see alot of it in the code (put your connection string) and in my case im using Visual Basic 2010 and i need to connect it to Data.SqlClient.Sqlconnection, i heard that my string should look like this:
("server=*****;Port=3306; User ID=*****; password=****; database=*****")
but I don't know what I should put in server, userid, password and the database.
first of all what i should type in "server" ?
and for the userid and the pass, is it me choosing it or there is a known userid and pass i have to put!?
I know my questions are stupid but i really need your help
btw my db name is : Database1.sdf
thanks
Last edited by Jack Tomy; Jan 20th, 2012 at 05:10 PM.
-
Jan 20th, 2012, 04:01 PM
#2
Re: Connection Strings ?
sdf makes it look like SQL CE - is that so?
Go to connectionstrings.com and you will get good examples...
-
Jan 20th, 2012, 04:10 PM
#3
Thread Starter
Junior Member
Re: Connection Strings ?
yes szlamany i went to connetionstings.com, i told u that my connections string look like this :
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
but i dont know what i must put in server, database, username and password !
-
Jan 20th, 2012, 04:12 PM
#4
Re: Connection Strings ?
That all important question I asked...
sdf makes it look like SQL CE - is that so?
[edit] CE - compact edition... [/edit]
-
Jan 20th, 2012, 04:15 PM
#5
Thread Starter
Junior Member
Re: Connection Strings ?
i really dont know what you mean with ur question, im not expert in VB.NET
but i can tell that it gives me this error :
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
what i realized that the program cannot reach the db, so i said that the problem maybe from the connection string
-
Jan 20th, 2012, 04:18 PM
#6
Re: Connection Strings ?
Do you have MS SQL Server - which is an additional product - running on your machine?
Normally a .SDF is a MS SQL COMPACT EDITION file - there is connection strings for that here
http://connectionstrings.com/sql-server-2005-ce
And it uses a different namespace for access...
You need to tell us what you are using.
-
Jan 20th, 2012, 04:18 PM
#7
Thread Starter
Junior Member
Re: Connection Strings ?
oh okay just a moment i'll check
-
Jan 20th, 2012, 04:21 PM
#8
Thread Starter
Junior Member
Re: Connection Strings ?
yes acually its :
Microsoft SQL Server Compact 3.5
i had my friend he told me that Microsoft SQL Server Compact 4.0 is realesed !
should i get it or smthing ?
-
Jan 20th, 2012, 04:24 PM
#9
Thread Starter
Junior Member
Re: Connection Strings ?
i think that i dont have MS !
also i m not using access db.
[Edited] im using Data.SqlClient.Sqlconnection, the link* u gave me is for: System.Data.SqlServerCe.SqlCeConnection [Edited]
-
Jan 20th, 2012, 04:28 PM
#10
Thread Starter
Junior Member
Re: Connection Strings ?
szlamany i know what is my connection sting, i know what i m using and i already notify that im using this connection string :
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
but i told u that i dont know what i must type in server place? should i type localhost or what ?
and about the username and password , what i should type , is it me who will choose user and pass?
-
Jan 20th, 2012, 04:51 PM
#11
Re: Connection Strings ?
You are using connection strings for MS SQL SERVER
This is the link for MS SQL CE
http://connectionstrings.com/sql-server-2005-ce
See how they don't ask for a SERVER but instead a DATASOURCE??
-
Jan 20th, 2012, 04:57 PM
#12
Thread Starter
Junior Member
Re: Connection Strings ?
ummm okay, sorry for being stupid !!
anyways my connection string now looks like this :
Data Source=C:\Users\Houssin\Documents\Visual Studio 2010\Projects\sqlclient\sqlclient\Database1.sdf;Persist Security Info=False;
but i still got this error :
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
-
Jan 20th, 2012, 05:00 PM
#13
Re: Connection Strings ?
Now that you have the correct connection string - you have to use the correct namespace
System.Data.SqlServerCe.SqlCeConnection
-
Jan 20th, 2012, 05:04 PM
#14
Thread Starter
Junior Member
Re: Connection Strings ?
okay i will use it and reply u just a moment
-
Jan 20th, 2012, 05:09 PM
#15
Thread Starter
Junior Member
Re: Connection Strings ?
Perfectly worked!!
Thanks a lot szlamany for helping me solve this problem
-
Jan 20th, 2012, 05:10 PM
#16
Re: Connection Strings ?
No problem - easy to be confused with the different name spaces and what not!
Mark your thread resolved! [edit] I see your already did [/edit]
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
|