各位大侠请帮忙看看这个是为什么的
string strProName = "inserttest";
string connString = DBUtility.SqlHelper.connString;
CommandType comType = CommandType.StoredProcedure;
SqlParameter[] paras ={
new SqlParameter("@name", SqlDbType.VarChar, 50) };
paras[0].Value = "hao";
int val = DBUtility.SqlHelper.ExecuteNonQuery(connString, comType, strProName, paras);上面是我编写windows服务的时候需要引用到的dll里面的数据库操作出来的方法。可是注册服务之后,上面的插入数据是没动静的。不知道为什么,引用是没问题的,因为我能点出DBUtility.SqlHelper.xxx方法来假如我使用原始的方法:
SqlConnection sqlCon = new SqlConnection("Data Source=.;Initial Catalog=member;User ID=sa;pwd=sa");
sqlCon.Open();
string strSql = "insert into dbo.test2 values('"+value +"')";
SqlCommand sqlCom = new SqlCommand(strSql, sqlCon);
sqlCom.ExecuteNonQuery();
sqlCon.Close();
这样测试的结果是有数据插入的。请问是什么原因?谢谢
string strProName = "inserttest";
string connString = DBUtility.SqlHelper.connString;
CommandType comType = CommandType.StoredProcedure;
SqlParameter[] paras ={
new SqlParameter("@name", SqlDbType.VarChar, 50) };
paras[0].Value = "hao";
int val = DBUtility.SqlHelper.ExecuteNonQuery(connString, comType, strProName, paras);上面是我编写windows服务的时候需要引用到的dll里面的数据库操作出来的方法。可是注册服务之后,上面的插入数据是没动静的。不知道为什么,引用是没问题的,因为我能点出DBUtility.SqlHelper.xxx方法来假如我使用原始的方法:
SqlConnection sqlCon = new SqlConnection("Data Source=.;Initial Catalog=member;User ID=sa;pwd=sa");
sqlCon.Open();
string strSql = "insert into dbo.test2 values('"+value +"')";
SqlCommand sqlCom = new SqlCommand(strSql, sqlCon);
sqlCom.ExecuteNonQuery();
sqlCon.Close();
这样测试的结果是有数据插入的。请问是什么原因?谢谢
确定数据库连接字符创正确?
确定存储过程正确,在member库中存在?
确定数据库服务启动了?
CommandType comType = CommandType.text
改为CommandType comType = CommandType.text
先一个窗体工程作为宿主启动程序,如果没有问题,那么用NTserver作为宿主启动程序也没问题(给足权限)。