I am using Imports System.Data.SqlClient, which I assume means that my data handling is ADO.Net.

strCityType is a string but if the field is left blank I dont want anything for that field sent to the database. That is unless I can send something that will tell the database to keep the field a <NULL>. Because an empty string will not work for the application.

Off the top of my head the only thing I can think of to get around this is to have two different Insert Statements and then test for a value in the txtCityTax text box. If there is something in that box send the Insert Statement with the txtCityTax data. If not send the Insert Statement without the data included. For instrance:

VB Code:
  1. If txtcity.text = "" Then
  2.             With cmd
  3.                 .CommandText = "Insert Into myTable (" & _
  4.                     "Co, " & _
  5.                     "BatchTransType" & _
  6.                     ") Values(" & _
  7.                     intCo & ", " & _
  8.                     "'" & strBatchTransType & "')"
  9.                 .ExecuteNonQuery()
  10.             End With
  11.         Else
  12.             With cmd
  13.                 .CommandText = "Insert Into myTable (" & _
  14.                     "Co, " & _
  15.                      "BatchTransType, " & _
  16.                     "LocalCode" & _
  17.                     ") Values(" & _
  18.                     intCo & ", " & _
  19.                     "'" & strBatchTransType & "', " & _
  20.                     "'" & strCityTax & "'" & ")"
  21.                 .ExecuteNonQuery()
  22.             End With
  23.         End If
It just seems like that is a horrible way to accomplish what I am trying to do. Is there an alternative?