G
Guest
Dear all,
I have a function name GetLabData which call a store procedure .
For that function I need to create the Adapter.InsertCommand an DeleteCommand
My InsertCommand works fine and build as follow :
======================>
m_SQl_Insert = "insert into External_Data LINE_ID) "
m_SQl_Insert = m_SQl_Insert & "values (@Line_id)"
m_ObjSqDeleteCmd = New SqlCommand(m_SQl_Insert, m_sqlConn)
m_ObjSqDeleteCmd.Parameters.Clear()
m_ObjSqDeleteCmd.Parameters.Add("@Line_id", SqlDbType.NVarChar, 16,
"LINE_ID")
m_ObjSqlInsertCmd = New SqlCommand(m_SQl_Insert, m_sqlConn)
m_ObjSqlInsertCmd.Parameters.Clear()
m_ObjSqlInsertCmd.Parameters.Add("@Line_id", SqlDbType.NVarChar, 16,
"LINE_ID")
m_ObjSqlInsertCmd.CommandType = CommandType.Text
m_objLabAdapter.InsertCommand = m_ObjSqlInsertCmd
<======================
As soon as I do the same thing for the DeleteCommand, I get an exception
when that command gets call by the Adapter.Update method
What is the proper way to define Adapter command (Insert,Delete,Update) ???
I do the following for the DeletCommand but does not work :
===========>
m_SQl_Insert = "DELETE FROM EXTERNAL_DATA WHERE "
m_SQl_Insert = m_SQl_Insert & "Line_ID=' wse30'"
m_ObjSqDeleteCmd.CommandType = CommandType.Text
m_objLabAdapter.DeleteCommand = m_ObjSqDeleteCmd
What I ma doing wrong ? not that I have test those commnd within TSQL and
works ok
thanks for your help
regards
serge
I have a function name GetLabData which call a store procedure .
For that function I need to create the Adapter.InsertCommand an DeleteCommand
My InsertCommand works fine and build as follow :
======================>
m_SQl_Insert = "insert into External_Data LINE_ID) "
m_SQl_Insert = m_SQl_Insert & "values (@Line_id)"
m_ObjSqDeleteCmd = New SqlCommand(m_SQl_Insert, m_sqlConn)
m_ObjSqDeleteCmd.Parameters.Clear()
m_ObjSqDeleteCmd.Parameters.Add("@Line_id", SqlDbType.NVarChar, 16,
"LINE_ID")
m_ObjSqlInsertCmd = New SqlCommand(m_SQl_Insert, m_sqlConn)
m_ObjSqlInsertCmd.Parameters.Clear()
m_ObjSqlInsertCmd.Parameters.Add("@Line_id", SqlDbType.NVarChar, 16,
"LINE_ID")
m_ObjSqlInsertCmd.CommandType = CommandType.Text
m_objLabAdapter.InsertCommand = m_ObjSqlInsertCmd
<======================
As soon as I do the same thing for the DeleteCommand, I get an exception
when that command gets call by the Adapter.Update method
What is the proper way to define Adapter command (Insert,Delete,Update) ???
I do the following for the DeletCommand but does not work :
===========>
m_SQl_Insert = "DELETE FROM EXTERNAL_DATA WHERE "
m_SQl_Insert = m_SQl_Insert & "Line_ID=' wse30'"
m_ObjSqDeleteCmd.CommandType = CommandType.Text
m_objLabAdapter.DeleteCommand = m_ObjSqDeleteCmd
What I ma doing wrong ? not that I have test those commnd within TSQL and
works ok
thanks for your help
regards
serge