有没有办法可以将OO概念应用于向查询添加连接字符串?每当我想在asp.net中编写查询时,我必须反复输入连接字符串
答案 0 :(得分:2)
public class dbhandler
{
private SqlConnection con;
private string ConnectionString;
public dbhandler()
{
ConnectionString ="Your connection string here";
}
public SqlConnection Connect()
{
con = new SqlConnection(ConnectionString);
}
}