1
我得到異常後的結果。爲什麼sqlcomm
試圖找到doTable
默認表字符串'blTableName'?我不會將此名稱發送到sqlcomm
,所以我需要查看sqlcomm
已執行的SQL查詢。Sqlcommand去執行
這是數據庫中添加參數「表名」表,但無論如何例外,而不是返回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'
}
,你能否告訴了'TableUpdate' SP? –
exception message =「無效的對象名稱blTableName'。」 SP = @table(nvharchar(128),輸入,無默認值) @TablePK(uniqueidentifier,Input,無默認值) –
使用SQL Server自帶的SQL Server Management Studio(SSMS)。該工具中有一個瀏覽器,可以查看錶和存儲過程。您需要查看數據庫中的存儲過程TableUpdate。 – jdweng