(1)
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
InitPageData(vid); // 这个vid是什么?没声明、没初始化就调用?
}
(2)
protected void update_Click(object sender, System.EventArgs e)
{
a=VendorName.Text;
VendorDetails.UpdateVendor(a);//UpdateVendor是一个方法,该方法在数据库运行是正确的
}
这个就更看不懂了,a是什么?
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
InitPageData(vid); // 这个vid是什么?没声明、没初始化就调用?
}
(2)
protected void update_Click(object sender, System.EventArgs e)
{
a=VendorName.Text;
VendorDetails.UpdateVendor(a);//UpdateVendor是一个方法,该方法在数据库运行是正确的
}
这个就更看不懂了,a是什么?
解决方案 »
- 做一个站内搜索需要注意哪些问题?
- 用asp.net的mvc显示员工信息列表(在表格中显示员工列表)
- string yqId = Request["yqId"].ToString();//取出传递来的参数 这句的yqId类型是varchar类型,如果是整形该怎样
- 如何设置MSN默认用户
- 有没有哪位高人用过Grove orm映射工具生成实体(50分)
- 兄弟们,这种错误是什么意思啊??
- 怎样控制不同角色的访问权限?
- 关于ajax控件timer 设置刷新执行下一条数据问题
- asp.net mvc中如何实现隐藏url的泛二级域名
- 请教DataGrid,Repeater和DataList的区别及其使用的场合。
- AG: ASP.NET DataGrid 单击一行或双击一行后在屏幕一区域内显示数据问题???
- asp.net 关于错误信息页面?
有问题再说啊!
private void Page_Load(object sender, System.EventArgs e)
{
if(IsPostBack)
{return;}
Binder();
}
void Binder()
{
SqlConnection conn=new SqlConnection("server=.;uid=sa;pwd=;database=model");
SqlDataAdapter da=new SqlDataAdapter("select * from product where productID='"+Label1.Text+"'",conn);
DataSet ds=new DataSet();
da.Fill(ds); TextBox2.Text=ds.Tables[0].Rows[0][2].ToString();
}
private void Button1_Click(object sender, System.EventArgs e)
{
Session.Add("aa",TextBox2.Text);
SqlConnection conn=new SqlConnection("server=.;uid=sa;pwd=;database=model");
SqlCommand cmd=new SqlCommand("UPDATE product SET productContent ='"+Session["aa"]+"' WHERE ( productID ='"+Label1.Text+"')",conn); conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
a完全是我用来检验值 设置的一个变量。
VendorDetails.UpdateVendor(a);//UpdateVendor是一个方法,该方法在数据库运行是正确的
用这个方法 要把数据库里的一个字段的值更新为a
我的方法是这样的
public static int UpdateVendor(string name)
{
string connectionString = ConfigurationManager.ConnectionStrings["RemoteTestConnectionString"].ConnectionString;
System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);
string queryString = "UPDATE [vendors] SET [vendor_nm]=@name";
System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand(); dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection; System.Data.IDataParameter dbParam_name = new System.Data.SqlClient.SqlParameter(); dbParam_name.ParameterName = "@name";
dbParam_name.Value = name;
dbParam_name.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_name);
int rowsAffected = 0; dbConnection.Open();
try
{
rowsAffected = dbCommand.ExecuteNonQuery();
}
finally
{
dbConnection.Close();
}
return rowsAffected;
}