Delete Command - By Parameter - Problem()
-
I have a Dataadapter, by select query. During datasave, getting problem with delete command.It's not working. I need to delete the null values. So how to pass the parameters? Dim Save_3 As String = "Delete from gnlmst where gnl_code is null" DAD.DeleteCommand = New SqlCommand(Save_3, con) With DAD.DeleteCommand.Parameters .Add("@???????", SqlDbType.VarChar, 0, "gnl_code") End With Thanks:thumbsup:
-
I have a Dataadapter, by select query. During datasave, getting problem with delete command.It's not working. I need to delete the null values. So how to pass the parameters? Dim Save_3 As String = "Delete from gnlmst where gnl_code is null" DAD.DeleteCommand = New SqlCommand(Save_3, con) With DAD.DeleteCommand.Parameters .Add("@???????", SqlDbType.VarChar, 0, "gnl_code") End With Thanks:thumbsup:
Paramu1973 wrote:
Dim Save_3 As String = "Delete from gnlmst where gnl_code is null"
whether you try like following
Dim Save_3 As String = "Delete from gnlmst where @gnl_code is NULL" DAD.DeleteCommand = New SqlCommand(Save_3, con) With DAD.DeleteCommand.Parameters Add("@gnl_code", SqlDbType.VarChar, 50).Value = "gnl_code" End With
rup28aug@yahoo.co.in Rupesh Kumar Swami Software Developer, Integrated Solution, Bikaner (India) My Company Award: Best VB.NET article of June 2008: Create Column Charts Using OWC11
-
Paramu1973 wrote:
Dim Save_3 As String = "Delete from gnlmst where gnl_code is null"
whether you try like following
Dim Save_3 As String = "Delete from gnlmst where @gnl_code is NULL" DAD.DeleteCommand = New SqlCommand(Save_3, con) With DAD.DeleteCommand.Parameters Add("@gnl_code", SqlDbType.VarChar, 50).Value = "gnl_code" End With
rup28aug@yahoo.co.in Rupesh Kumar Swami Software Developer, Integrated Solution, Bikaner (India) My Company Award: Best VB.NET article of June 2008: Create Column Charts Using OWC11
Thanks. :) Tried. But It's Not Deleting.
-
Thanks. :) Tried. But It's Not Deleting.
try following
Dim QueryText As String dim fieldName as string ="Field1" Dim command As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand() QueryText ="delete from table where @field is NULL" command.CommandText = QueryText command.Parameters.Add("@field", SqlDbType.Varchar, fieldName.length).Value = fieldName
rup28aug@yahoo.co.in Rupesh Kumar Swami Software Developer, Integrated Solution, Bikaner (India) My Company Award: Best VB.NET article of June 2008: Create Column Charts Using OWC11