估计是调用部分错了,给你看一段c#调用sqlserver的:
public DataTable FetchAllAssets()
{
string sproc = "fetch_all_assets";//存储过程名称
OleDbCommand oCommand = new OleDbCommand(sproc);
oCommand.CommandType = CommandType.StoredProcedure;
                      //如果有参数还得在此设置、赋值.....
DataSet oDataSet = new DataSet();
OleDbDataAdapter oData = new OleDbDataAdapter(oCommand);
DataSet oDataSet = new DataSet();
oData.Fill(oDataSet); DataTable oTable = oDataSet.Tables[0];
return oTable;
}
如下:public int InsertAsset(
string assetTitle, 
string assetText, 
int subjectID1,
int subjectID2,
int subjectID3,
int subjectID4,
int subjectID5)
{
string sproc = "insert_asset";
OleDbCommand oCommand = new OleDbCommand(sproc);
oCommand.CommandType = CommandType.StoredProcedure;

OleDbParameter p1 = new OleDbParameter("@title", OleDbType.VarChar, 100);
p1.Value = assetTitle;
oCommand.Parameters.Add(p1); OleDbParameter p2 = new OleDbParameter("@asset", OleDbType.Text);
p2.Value = assetText;
oCommand.Parameters.Add(p2);

OleDbParameter p3 = new OleDbParameter("@subject_id_1", OleDbType.Int, 4);
p3.Value = subjectID1;
oCommand.Parameters.Add(p3); OleDbParameter p4 = new OleDbParameter("@subject_id_2", OleDbType.Int, 4);
p4.Value = subjectID2;
oCommand.Parameters.Add(p4); OleDbParameter p5 = new OleDbParameter("@subject_id_3", OleDbType.Int, 4);
p5.Value = subjectID3;
oCommand.Parameters.Add(p5); OleDbParameter p6 = new OleDbParameter("@subject_id_4", OleDbType.Int, 4);
p6.Value = subjectID4;
oCommand.Parameters.Add(p6); OleDbParameter p7 = new OleDbParameter("@subject_id_5", OleDbType.Int, 4);
p7.Value = subjectID5;
oCommand.Parameters.Add(p7); oConnection.Open();
if (oConnection.State != ConnectionState.Open)
{
string msg = "Error: Could not open the database.";
Exception ConnectionFailure = new Exception(msg);
throw ConnectionFailure;
}
int affRows = oCommand.ExecuteNonQuery();
oConnection.Close();

return affRows;
}

解决方案 »

  1.   

    看来你是从学asp过来的,老是忘不了以前的写法!
      

  2.   

    int affRows = oCommand.ExecuteNonQuery();
    只对INSERT,DELETE,UPDATE有效
    如果是验证身份的话,应该用ExecuteScalar()
      

  3.   

    conn.Open .... 之后
    conn.CursorLocation=3
    即可
      

  4.   

    特别感谢wanghuixue(辉),在不修改原来框架的情况下,可以运行了。再次感谢各位