例如:
table1 userid username
table2 bookid bookname
把上面两个表的内容插入到 下面这个表
table3 userid username bookid bookname
点击BUTTON 控件 把表插入
怎么解决
string connStr1 = "server=localhost;uid=sa; pwd=sa; database=book";
SqlConnection myConnection1 = new SqlConnection(connStr1);
string borrowStr = "select count(*) from borrowinfo ";
SqlCommand myCommand1 = new SqlCommand(borrowStr, myConnection1);
myConnection1.Open();
myCommand1.ExecuteNonQuery();
myConnection1.Close();
borrowStr= borrowStr + 1;
try
{
string insertStr = "insert into borrowinfo values ('" + borrowStr + "', '" + Request["bookname"] + "',getdate(),getdate())";
SqlCommand myCommand2 = new SqlCommand(insertStr, myConnection1);
myConnection1.Open();
myCommand2.ExecuteNonQuery();
Label12.Text = "插入成功!";
}
catch
{
Label12.Text = "插入失败!";
}
为什么总是 插入失败啊 不能 这样用吗