如何在asp.net中实现Sql helper类

时间:2022-09-02 12:06:07
SqlHelper.ExecuteNonQuery(conString, CommandType.StoredProcedure, "UserRegister_Insert",
                        new SqlParameter("@firstname",SqlDbType.NVarChar,50),
                        new SqlParameter("@lastname",LastName),
                        new SqlParameter("@email",Email),
                        new SqlParameter("@password",Password),
                        new SqlParameter("@contactno",ContactNo));

I have also implemented sql helper class but the members of that class are unable to access.

我还实现了sql helper类,但该类的成员无法访问。

1 个解决方案

#1


Error at connection string that it is not defined in current context ?
Please take a string variable and initialize it just above your code and try to run it

在当前上下文中未定义的连接字符串出错?请使用字符串变量并在代码上方初始化它并尝试运行它

String conString=System.Configuration.ConfigurationManager.
    ConnectionStrings["connectionStringName"].ConnectionString;//your connection string name
SqlHelper.ExecuteNonQuery(conString, CommandType.StoredProcedure, "UserRegister_Insert",
                        new SqlParameter("@firstname",SqlDbType.NVarChar,50),
                        new SqlParameter("@lastname",LastName),
                        new SqlParameter("@email",Email),
                        new SqlParameter("@password",Password),
                        new SqlParameter("@contactno",ContactNo));

#1


Error at connection string that it is not defined in current context ?
Please take a string variable and initialize it just above your code and try to run it

在当前上下文中未定义的连接字符串出错?请使用字符串变量并在代码上方初始化它并尝试运行它

String conString=System.Configuration.ConfigurationManager.
    ConnectionStrings["connectionStringName"].ConnectionString;//your connection string name
SqlHelper.ExecuteNonQuery(conString, CommandType.StoredProcedure, "UserRegister_Insert",
                        new SqlParameter("@firstname",SqlDbType.NVarChar,50),
                        new SqlParameter("@lastname",LastName),
                        new SqlParameter("@email",Email),
                        new SqlParameter("@password",Password),
                        new SqlParameter("@contactno",ContactNo));