C#+Access查询值的数目与目标字段中的数目不同
OleDbCommandcmd2=newOleDbCommand();cn1.Open();stringsql,sql1,sql2;sql1="INSERTINTOStu...
OleDbCommand cmd2 = new OleDbCommand();
cn1.Open();
string sql, sql1, sql2;
sql1 = "INSERT INTO StudentInfo (StuID,StuName,Sex,Race,Address,Tel,EntranceYear,ClassID,Academy,Specialty,Role,Postal";
sql2 = " VALUES ('" + idbox.Text.ToString() + "','" + namebox.Text.ToString() + "','" + sexbox.Text.Trim() + "','" + racebox.Text.ToString() + "','" + addressbox.Text.ToString() + "','" + telbox.Text.ToString() + "','" + yearbox.Text.Trim() + "','" + banjibox.Text.Trim() + "','" + xueyuanbox.Text.Trim() + "','" + zhuanyebox.Text.Trim() + "','" + rolebox.Text.ToString() + "','" + postalbox.Text.ToString() + "'";
cmd2.Connection = cn1;
sql = sql1 + ")" + sql2 + ")";
cmd2.CommandText = sql;
cmd2.ExecuteNonQuery();
cn1.Close();
MessageBox.Show("学生信息添加成功");
我的Access数据库为 展开
cn1.Open();
string sql, sql1, sql2;
sql1 = "INSERT INTO StudentInfo (StuID,StuName,Sex,Race,Address,Tel,EntranceYear,ClassID,Academy,Specialty,Role,Postal";
sql2 = " VALUES ('" + idbox.Text.ToString() + "','" + namebox.Text.ToString() + "','" + sexbox.Text.Trim() + "','" + racebox.Text.ToString() + "','" + addressbox.Text.ToString() + "','" + telbox.Text.ToString() + "','" + yearbox.Text.Trim() + "','" + banjibox.Text.Trim() + "','" + xueyuanbox.Text.Trim() + "','" + zhuanyebox.Text.Trim() + "','" + rolebox.Text.ToString() + "','" + postalbox.Text.ToString() + "'";
cmd2.Connection = cn1;
sql = sql1 + ")" + sql2 + ")";
cmd2.CommandText = sql;
cmd2.ExecuteNonQuery();
cn1.Close();
MessageBox.Show("学生信息添加成功");
我的Access数据库为 展开
1个回答
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询