Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm trying to connect to an sql database using the following connection string

VB
Dim strCon As String = "Data Source=DATABASE,2048;Initial Catalog=STUFF;User Id=domain\username; Password=12345678"


when using this i get login failed for domain\username

but if I use

VB
Dim strCon As String = "Data Source=DATABASE,2048;Initial Catalog=STUFF;Trusted Connection=Yes;


then is works fine as i am logged in under my own domain login details while coding.

I need to be able to use my username and password in the connection string as i will be running the application on a different pc under another user. Access to the databases in our company a strictly controlled so I can't get access for the other users.
Is there something else I need in the connection string.

Thanks
J
Posted
Comments
[no name] 20-Sep-12 6:53am    
If you open the database and look at the security, does your username have a security role assigned and access to the "stuff" database?

Yes, need to visit http://www.connectionstrings.com/[^].

Have a nice day.
 
Share this answer
 
"Data Source=ServerName;Initial Catalog=DatabaseName;User Id=username; Password=password"

Happy Coding!
:)
 
Share this answer
 
v3
Comments
johnjsm 20-Sep-12 7:17am    
That is what i am already using and its not working
Aarti Meswania 20-Sep-12 7:19am    
you have write - 'Data Source=DATABASE'
it is 'Data Source=ServerName'

and Database name will be assigned to 'Initial Catalog'
Aarti Meswania 20-Sep-12 7:21am    
for example

Data Source=My-PC\SQLEXPRESS;Database=MyDatabase;uid=sa;pwd=sa

or

Data Source=My-PC\SQLEXPRESS;Initial Catalog=MyDatabase;uid=sa;pwd=sa
johnjsm 20-Sep-12 7:22am    
sorry. this is what i have.
"Data Source=ServerName,2048;Initial Catalog=DATABASE;User Id=domain\username; Password=12345678"
Aarti Meswania 20-Sep-12 7:26am    
open sql server copy server-name from sql's login window and paste it after
Data Source=________
from same window username & password
and then your database name
Hi Try this,

Data Source=.\data123;Initial Catalog=DBDesign;Integrated Security=True;Integrated Security=True;User ID=sa;Password=*****" providerName="System.Data.SqlClient"


Happy coding....
 
Share this answer
 
Hi Please try the below one.


Data Source=ServerName;Initial Catalog=Database Name;User ID=UserID;Password=Password providerName="System.Data.SqlClient" connnectionType="SQL"

regards
Chandru
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900