我要编辑文本框值.. 但我看到有问题
protected void btn_edit_Click(object sender, EventArgs e)
{
DatabaseConnector con = new DatabaseConnector().CreateInstance();
SqlCommand com = new SqlCommand("UPDATE tbl_BinCardManager SET ItemName = @ItemName WHERE ItemNo = @ItemNo");
com.Parameters.Add("@ItemName",sqlDbType.VarChar);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
错误 1:
当前上下文中不存在名称“sqlDbType”
错误 2:
“ERPSystem.DatabaseConnector”不包含“Open”的定义,并且找不到接受“ERPSystem.DatabaseConnector”类型的第一个参数的扩展方法“Open”(您是否缺少 using 指令或程序集引用?)
我的 DBConnector 类是:
class DatabaseConnector
{
private DatabaseConnector databaseConnector;
private string connectionString = "Data Source=lernlap;Initial Catalog=ERPSystemDB;User ID=sa;Password=sa123";
public DatabaseConnector()
{
}
private SqlConnection connection;
private bool Connect()
{
try
{
connection = new SqlConnection(connectionString);
connection.Open();
return true;
}
catch(Exception) {
return false;
}
}
internal DatabaseConnector CreateInstance()
{
if (databaseConnector == null)
{
databaseConnector = new DatabaseConnector();
databaseConnector.Connect();
}
return databaseConnector;
}