日期:2014-05-18 浏览次数:20459 次
try { string sql = @"insert into user(user_name,user_psw,group_id,ext_pri) values ('@name','@psw',@group,'@ext')"; OleDbConnection odc = new OleDbConnection(con_str); odc.Open(); OleDbCommand myAccessCommand = new OleDbCommand(sql, odc); OleDbParameter par = new OleDbParameter("@name", this.UserName.Text); myAccessCommand.Parameters.Add(par); par = new OleDbParameter("@psw", this.Password1.Text); myAccessCommand.Parameters.Add(par); par = new OleDbParameter("@group", this.WorkSelect.SelectedValue); myAccessCommand.Parameters.Add(par); par = new OleDbParameter("@ext", this.CheckBox1.Checked ? "100" : "0"); myAccessCommand.Parameters.Add(par); myAccessCommand.ExecuteNonQuery(); } catch (Exception error) { this.Label1.Text = "注册失败"; } finally { if (odc.State == ConnectionState.Open) odc.Close(); }
insert into user(user_name,user_psw,group_id,ext_pri) values ('name','psw',55,'ext')
string sql = "insert into [user](user_name,user_psw,group_id,ext_pri) values (@name,@psw,@group,@ext)";
------解决方案--------------------
string sql = "insert into [user](user_name,user_psw,group_id,ext_pri) values (@name,@psw,@group,@ext)";
user 表名需要加标志