data type synchronization

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,
I have three different data types coming out of my SQL tables that I
need to align with my VB code and the data set properties. I'm
getting an error message that reads "SQL exception unhandled. The
data types text and nvarchar are incompatible in the equal to
operator." Here is the relevant code.

Dim da As New SqlDataAdapter(strSQL, cn)
da.SelectCommand.Parameters.AddWithValue("@OrderID",
tbOrderID.Text)

Dim tbl As New DataTable("Orders")
With tbl
.Columns.Add("OrderID", GetType(String))
.Columns.Add("Price", GetType(Decimal))
.Columns.Add("Item", GetType(Integer))
End With
da.Fill(tbl)

Previously, I had all of the fields set to text in SQL, String in the
VB code and System.String in the data set properties. Everything
executed fine. However, when I tightened up my data types, attempting
to change them to their correct types, the app crashed. That was the
only thing that I changed between successful runs and the run-time
error.

So I suspect that I just have some sort of contradiction in how I have
set the data types in the various settings (sql, vb code, data set).
I have attempted to synchronize these data types using:
Text (sql), String (vb code), System.String (data set
properties);
Money, Decimal, System.Decimal;
Int, Integer, System.Int16.
No matter what I try, I get the exact same error.

Am I right or is the error message coming from somewhere else? Also,
does anybody know of a reference that shows what data types are
"legal" matches between these different settings?

I appreciate any help.
Alex

.



Relevant Pages

  • Re: data type synchronization
    ... I have three different data types coming out of my SQL tables that I ... VB code and System.String in the data set properties. ... Am I right or is the error message coming from somewhere else? ...
    (microsoft.public.dotnet.framework.adonet)
  • data type synchronization
    ... I have three different data types coming out of my SQL tables that I ... VB code and System.String in the data set properties. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: New user help and Excel read question (Interop and OleDb)
    ... Regards, ... Tom Ogilvy ... > Well I'm able to convert the assumed data types on the fly after the ... > data set is filled and I'm pulling out values. ...
    (microsoft.public.excel.programming)
  • Re: New user help and Excel read question (Interop and OleDb)
    ... Well I'm able to convert the assumed data types on the fly after the ... data set is filled and I'm pulling out values. ... data set with NO datatype guessing??? ... sporadicPosted from http://www.pcreview.co.uk/ newsgroup access ...
    (microsoft.public.excel.programming)
  • Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
    ... simple embedded database as SQL-compliant as possible. ... It's just that it's not SQL, ... "If switching to a larger database such as PostgreSQL or Oracle ... has an issue with dynamic data types and in HIS version of Python, ...
    (comp.lang.python)