c# - 'SqlConnection' does not contain a constructor that takes 4 arguments -
this code:
public void sqldbconnect() { sqlconnection conn = new sqlconnection("data source={0};user id={1};password={2};", server, user, password); conn.open(); }
i try make connection via server name, user , pass.
you need format string , pass string constructor (this c# 6 specific feature):
sqlconnection conn = new sqlconnection($"data source={server};user id={user};password={password};");
or in older c# versions can use string.format
:
sqlconnection conn = new sqlconnection(string.format("data source={0};user id={1};password={2};", server, user, password));
Comments
Post a Comment