sqlcommand去cachtch
Sqlcommand going cahtch
结果出现异常。为什么 sqlcomm
试图找到 doTable
默认 table 字符串 'blTableName'?我不会将此名称发送到 sqlcomm
的任何地方,因此我需要查看 sqlcomm
执行的 SQL 查询。
它是将参数添加到数据库到 'TableName' table 但无论如何异常,不返回 1
string t_table_name = "TableName";
try
{
BindingList<doTable> bl = new
daTable().getTable(CoreStatic.s_SqlServerConfigLocal, new doTable() { table_ = t_table_name, TablePK = p_doWcfTicketQueue.TablePK, TableBFK =
CoreStatic.s_CurrentBPK }, Enums.DynamicType.BindingList);
foreach (doTable item_odoTable in bl)
{
SqlConnection SqlConn = new SqlConnection(blabla);
SqlCommand sqlcomm = new SqlCommand("TableUpdate", SqlConn);
SqlConn.Open();
sqlcomm.CommandType = CommandType.StoredProcedure;
sqlcomm.Parameters.Add(new SqlParameter()
{ ParameterName = "@table", SqlDbType = SqlDbType.NVarChar, Direction = ParameterDirection.Input, Value = t_table_name });
sqlcomm.Parameters.Add(new SqlParameter()
{ ParameterName = "@TablePK", SqlDbType = SqlDbType.UniqueIdentifier, Direction = ParameterDirection.Input, Value = item_odoTable.TablePK });
//is that possible to see sqlcomm sql query? like" insert into TableName... bla bla "
result = sqlcomm.ExecuteNonQuery();
}//try
catch (SqlException exc)
{
//exc = invalid object name 'blTableName'
}
我在尝试修改我写错的地方的存储过程时发现了问题。
但我仍然想看看 sqlcomm.ExecuteNonQuery
作为 SQL 查询发送的内容
insert into blTableName//wrong
insert into '+@table+'//right
结果出现异常。为什么 sqlcomm
试图找到 doTable
默认 table 字符串 'blTableName'?我不会将此名称发送到 sqlcomm
的任何地方,因此我需要查看 sqlcomm
执行的 SQL 查询。
它是将参数添加到数据库到 'TableName' table 但无论如何异常,不返回 1
string t_table_name = "TableName";
try
{
BindingList<doTable> bl = new
daTable().getTable(CoreStatic.s_SqlServerConfigLocal, new doTable() { table_ = t_table_name, TablePK = p_doWcfTicketQueue.TablePK, TableBFK =
CoreStatic.s_CurrentBPK }, Enums.DynamicType.BindingList);
foreach (doTable item_odoTable in bl)
{
SqlConnection SqlConn = new SqlConnection(blabla);
SqlCommand sqlcomm = new SqlCommand("TableUpdate", SqlConn);
SqlConn.Open();
sqlcomm.CommandType = CommandType.StoredProcedure;
sqlcomm.Parameters.Add(new SqlParameter()
{ ParameterName = "@table", SqlDbType = SqlDbType.NVarChar, Direction = ParameterDirection.Input, Value = t_table_name });
sqlcomm.Parameters.Add(new SqlParameter()
{ ParameterName = "@TablePK", SqlDbType = SqlDbType.UniqueIdentifier, Direction = ParameterDirection.Input, Value = item_odoTable.TablePK });
//is that possible to see sqlcomm sql query? like" insert into TableName... bla bla "
result = sqlcomm.ExecuteNonQuery();
}//try
catch (SqlException exc)
{
//exc = invalid object name 'blTableName'
}
我在尝试修改我写错的地方的存储过程时发现了问题。
但我仍然想看看 sqlcomm.ExecuteNonQuery
作为 SQL 查询发送的内容
insert into blTableName//wrong
insert into '+@table+'//right