它说这是“ DB_Student.TBLStudent”是无效的对象。这是为什么?

时间:2019-02-09 06:22:25

标签: c# sql

我从另一个数据库获取数据,第一个连接来自con,第二个数据库是DB_Student。我想从DB_Student获取签名并将其放入具有约束力的DB_Attendance中。

    SqlCommand cmd = new SqlCommand();
    cmd = con.CreateCommand();
    foreach (DataGridViewRow row in dgvAtt.Rows)
    {
      if (row.Cells.Count >= 4 && row.Cells[4].Value != null)
       {
         con.Open();
         cmd.CommandType = CommandType.Text;
         string Query = "INSERT INTO TBL_Attendance(Signature) SELECT 
         Signature FROM DB_Students.TBL_Student WHERE Name = '" + 
         row.Cells[4].Value.ToString() + "'";
         cmd.CommandText = Query;
         cmd.ExecuteNonQuery();
         con.Close();
        }
       else
        {
          MessageBox.Show("Please Delete the row without name.");
        } 

0 个答案:

没有答案