dotNet - syntax for parms in SQL Connection?

K

kate

I need to pass along parms in an SQLConnection.
EG
con = (New SqlConnection("Data Source=mySQLserver;user
id=UserName; password=UserPassword;Initial
Catalog=northwind"))

The function is passed the values as parms and needs to
pass them along to SQLServer.
ie:
<WebMethod()> Public Function ValidateUser(ByVal UserName
As String, _
ByVal UserPassword As String) As Boolean

I have tried UserName, @UserName, &UserName in the
SQLConnection string. None work.. It thinks it is a user
name in plain text.
What is the correct syntax for passing userid and password
so that the VALUES are passed, rather than the literal?

All the examples show either username/password in plain
text or "Integrated Security=SSPI;".

Thanks!
 
B

bruce barker

con = New SqlConnection( string.format("Data Source=mySQLserver;user
id={0}; password={1};Initial
Catalog=northwind",userName,userPwd))
 
S

Sudha

you can also do it this way :)

con = New SqlConnection("Data Source=mySQLserver;user
id="+userName +"; password="+userPwd+";Initial
Catalog=northwind")

Rgds
 

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

Top