无法将类型“system.data.sqlclient.sqlcommand” 隐式转换为“sqyqtem.data.sqlclient.sqlconnection”
privatevoid删除_Click(objectsender,EventArgse){if(MessageBox.Show("确定要删除该系信息吗?","删除提示",...
private void 删除_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定要删除该系信息吗?", "删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
try
{
com = new SqlCommand("delete from 系别表 where ID=" + Convert.ToString(dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value).Trim(), conn);//无法将“system.data.sqlclient.sqlcommand” 隐式转换为“sqyqtem.data.sqlclient.sqlconnection”
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
com.ExecuteNonQuery();//"system.data.sqlclient.sqlconnection"并不包含“executenonquery”的定义
conn.Close();
MessageBox.Show("删除数据成功!");
ClearText();
FillDataGridView();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
} 展开
{
if (MessageBox.Show("确定要删除该系信息吗?", "删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
try
{
com = new SqlCommand("delete from 系别表 where ID=" + Convert.ToString(dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value).Trim(), conn);//无法将“system.data.sqlclient.sqlcommand” 隐式转换为“sqyqtem.data.sqlclient.sqlconnection”
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
com.ExecuteNonQuery();//"system.data.sqlclient.sqlconnection"并不包含“executenonquery”的定义
conn.Close();
MessageBox.Show("删除数据成功!");
ClearText();
FillDataGridView();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询