incmd.ExecuteNonQuery();总是提示至少有一个参数没被指定值。
protected void Button1_Click(object sender, EventArgs e)
{
string inname = nameBox.Text.ToString();
string insex = sexddl.SelectedItem.ToString();
string incsny = csnybox.Text.ToString();
string inzc = zcbox.Text.ToString();
string inzw = zwbox.Text.ToString();
string ingzdw = gzdwbox.Text.ToString();
string inlxdh = lxdhbox.Text.ToString();
string inyb = ybbox.Text.ToString();
string incgtm = cgtmbox.Text.ToString();
string inktly = ktlybox.Text.ToString();
string inzgsc = zgscddl.SelectedItem.ToString();
string insub = subddl.SelectedItem.ToString();
string incglb = cglbddl.SelectedItem.ToString();
string inpflb = pflbddl.SelectedItem.ToString();
string infbtime = fbtimebox.Text.ToString();
string incgjj = cgjjbox.Text.ToString();
string inspqk = spqkbox.Text.ToString();
string inhjqk = hjqkbox.Text.ToString();
string inbz = bzbox.Text.ToString();
OleDbConnection Inconn = new OleDbConnection();
Inconn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source='j:/pro/project.mdb'";
Inconn.Open();
string instr = string.Format("insert into Info values ('{0}','{1}','{2}',{3},'{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}')", inname, insex, incsny, inzc, inzw, ingzdw, inlxdh, inyb, incgtm, inktly, inzgsc, insub, incglb, inpflb ,infbtime, incgjj, inspqk, inhjqk, inbz);
OleDbCommand incmd = new OleDbCommand(instr,Inconn);
incmd.ExecuteNonQuery();
Inconn.Close();
}
------解决方案--------------------把你表帖出来看看
检查表中有多少个字段?你的插入语句是有19个字段。。
是不是少了什么字段或者是多了字段?
------解决方案--------------------insert into Info(字段1,字段2,字段3,...) values("值1","值2","值3",...)
用上面这种指定字段的插入语句,顺便也能检查一下,是否有缺少字段
------解决方案--------------------
------解决方案--------------------你的字段类型都是字符串类型的吗?
你的内容里面有引号吗?
如果你不能确定,你最好是这样写
sql = "insert into Info (name,sex,csny,zc,zw,gzdw,lxdh,yb,cdtm,ktly,zgsc,sunject,cglb,pflb,fbtime,cgjj,spqk,hjqk,bz) values(@name,@sex,@csny,@zc,@zw,@gzdw,@lxdh,@yb,@cdtm,@ktly,@zgsc,@sunject,@cglb,@pflb,@fbtime,@cgjj,@spqk,@hjqk,@bz)"
incmd.Parameters.AddWithvalue("@name",inname);
incmd.Parameters.AddWithvalue("@sex",insex);
。。。。
其他类似
------解决方案--------------------