我想将 SqlCommand 结果转换为 Int 值我该怎么做?请帮助我尝试过的内容如下:
表中的 stp_no 已设置身份属性。我想将自动生成的数字插入另一个表,但它总是显示错误,如“Connot Convert SqlCommand Type to Int Type”
SqlCommand dvgcmd, snocmd;
snocmd = new SqlCommand("SELECT stp_no FROM MaterialTestMaster", con);
dvgcmd = new SqlCommand("INSERT INTO MaterialTestDetail(stp_no,test_no,test_name,test_type,test_spec,high_limit,low_limit)" +
"VALUES('"+ snocmd +"','" + @matTstDataGridView.Rows[j].Cells[0].Value + "'," +
" '" + @matTstDataGridView.Rows[j].Cells[1].Value + "'," +
" '" + @matTstDataGridView.Rows[j].Cells[2].Value + "'," +
" '" + @matTstDataGridView.Rows[j].Cells[3].Value + "'," +
" '" + @matTstDataGridView.Rows[j].Cells[4].Value + "'," +
" '" + @matTstDataGridView.Rows[j].Cells[5].Value + "')", con);
请帮助 M 解决这个问题 :)