{
OleDbConnection conn;
//OleDbDataAdapter adapter;
//string sqlstr;
int result = 0;
int count = 0;
string[,] strField = str2Field(sb, colum);
using (conn = new OleDbConnection(this.connstr))
{
//conn.Open();
OleDbCommand comm = new OleDbCommand("updateCaseInfo", conn);
comm.CommandType = CommandType.StoredProcedure;
OleDbParameter[] para ={
new OleDbParameter("@caseName",OleDbType.VarChar,50),
new OleDbParameter("@institutionName",OleDbType.VarChar,50),
new OleDbParameter("@institutionNature",OleDbType.VarChar,50),
new OleDbParameter("@province",OleDbType.VarChar,50),
new OleDbParameter("@happenTime",OleDbType.DBTimeStamp),
new OleDbParameter("@caseNature",OleDbType.VarChar,50),
new OleDbParameter("@leakForm",OleDbType.VarChar,50),
new OleDbParameter("@caseResource",OleDbType.VarChar,50),
new OleDbParameter("@treatment",OleDbType.VarChar,100),
new OleDbParameter("@exeName",OleDbType.VarChar,10),
new OleDbParameter("@caseState",OleDbType.VarChar,10),
};
int query = 0;
for (int t = 0; t < para.Length; t++)
{
comm.Parameters.Add(para[t]);
}
for (int i = 0; i < strField.GetLength(0); i++)
{
for (int j = 0; j < strField.GetLength(1); j++)
{
para[j].Value = strField[i, j];
}
try
{
if (conn.State == ConnectionState.Closed)
conn.Open();
if ((query = comm.ExecuteNonQuery()) > 0)
count += 1;
else
count += 0;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
Console.WriteLine("update {0} query {1}", count,query);
if (count == strField.GetLength(0))
result = 1;
return result;
}
}
6 个解决方案
#1
updateCaseInfo里面设置
set nocount on
set nocount on
#2
ExecuteNonQuery只返回影响行数,你的存储过程return(默认return)的值是不会显示的
也就是说,你在数据库的查询界面里执行这个存储过程下面如果显示影响行数:n,那么你的ExecuteNonQuery才可以看到数字
也就是说,你在数据库的查询界面里执行这个存储过程下面如果显示影响行数:n,那么你的ExecuteNonQuery才可以看到数字
#3
顶!
#4
CREATE PROCEDURE [dbo].[updateCaseInfo]
(
@caseName nvarchar(50),
@institutionName nvarchar(50),
@institutionNature nvarchar(50),
@province nvarchar(50),
@happenTime datetime,
@caseNature nvarchar(50),
@leakForm nvarchar(50),
@caseResource nvarchar(20),
@treatment nvarchar(50),
@exeName nvarchar(10),
@caseState nvarchar(10)
)
AS
SET NOCOUNT ON
update tablename
set
c1=@institutionName,
c2=@institutionNature,
c3=@province,
c4=@happenTime,
c5=@caseNature,
c6=@leakForm,
c7=@exeName,
c8=@caseState
where c0=@caseName
这样的存储过程是不是有错误呀?
(
@caseName nvarchar(50),
@institutionName nvarchar(50),
@institutionNature nvarchar(50),
@province nvarchar(50),
@happenTime datetime,
@caseNature nvarchar(50),
@leakForm nvarchar(50),
@caseResource nvarchar(20),
@treatment nvarchar(50),
@exeName nvarchar(10),
@caseState nvarchar(10)
)
AS
SET NOCOUNT ON
update tablename
set
c1=@institutionName,
c2=@institutionNature,
c3=@province,
c4=@happenTime,
c5=@caseNature,
c6=@leakForm,
c7=@exeName,
c8=@caseState
where c0=@caseName
这样的存储过程是不是有错误呀?
#5
数据库也没有update内容
#6
where c0=@caseName
可能是 @caseName 的值没弄好,单步看看
可能是 @caseName 的值没弄好,单步看看
#1
updateCaseInfo里面设置
set nocount on
set nocount on
#2
ExecuteNonQuery只返回影响行数,你的存储过程return(默认return)的值是不会显示的
也就是说,你在数据库的查询界面里执行这个存储过程下面如果显示影响行数:n,那么你的ExecuteNonQuery才可以看到数字
也就是说,你在数据库的查询界面里执行这个存储过程下面如果显示影响行数:n,那么你的ExecuteNonQuery才可以看到数字
#3
顶!
#4
CREATE PROCEDURE [dbo].[updateCaseInfo]
(
@caseName nvarchar(50),
@institutionName nvarchar(50),
@institutionNature nvarchar(50),
@province nvarchar(50),
@happenTime datetime,
@caseNature nvarchar(50),
@leakForm nvarchar(50),
@caseResource nvarchar(20),
@treatment nvarchar(50),
@exeName nvarchar(10),
@caseState nvarchar(10)
)
AS
SET NOCOUNT ON
update tablename
set
c1=@institutionName,
c2=@institutionNature,
c3=@province,
c4=@happenTime,
c5=@caseNature,
c6=@leakForm,
c7=@exeName,
c8=@caseState
where c0=@caseName
这样的存储过程是不是有错误呀?
(
@caseName nvarchar(50),
@institutionName nvarchar(50),
@institutionNature nvarchar(50),
@province nvarchar(50),
@happenTime datetime,
@caseNature nvarchar(50),
@leakForm nvarchar(50),
@caseResource nvarchar(20),
@treatment nvarchar(50),
@exeName nvarchar(10),
@caseState nvarchar(10)
)
AS
SET NOCOUNT ON
update tablename
set
c1=@institutionName,
c2=@institutionNature,
c3=@province,
c4=@happenTime,
c5=@caseNature,
c6=@leakForm,
c7=@exeName,
c8=@caseState
where c0=@caseName
这样的存储过程是不是有错误呀?
#5
数据库也没有update内容
#6
where c0=@caseName
可能是 @caseName 的值没弄好,单步看看
可能是 @caseName 的值没弄好,单步看看