Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Error during a dataSet fill

naiteknaitek Posts: 2Member
Hello All,

Any help besides changing the database information would be awesome as I can't seem to find help anywhere else.

Here is the debug info:


************** Exception Text **************
System.Data.SqlClient.SqlException: Syntax error converting the varchar value '`' to a column of data type int.
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.Common.DbDataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at WindowsApplication1.Form1.textBox1_Leave(Object sender, EventArgs e) in c:projectsvb-netwindowsapplication1form1.cs:line 139
at System.Windows.Forms.Control.OnLeave(EventArgs e)
at System.Windows.Forms.Control.NotifyLeave()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
WindowsApplication1
Assembly Version: 1.0.1782.31783
Win32 Version: 1.0.1782.31783
CodeBase: file:///c:/projects/vb-net/WindowsApplication1/bin/Debug/WindowsApplication1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.2032
CodeBase: file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:





When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.


thanks,

naitek

Comments

  • BaldusariusBaldusarius Posts: 162Member
    It would seem to me that one of the columns in the data set is configured to hold int objects, while the column it is mapped to in the database is not ('`' is not an int).

    : Hello All,
    :
    : Any help besides changing the database information would be awesome as I can't seem to find help anywhere else.
    :
    : Here is the debug info:
    :
    :
    : ************** Exception Text **************
    : System.Data.SqlClient.SqlException: Syntax error converting the varchar value '`' to a column of data type int.
    : at System.Data.SqlClient.SqlDataReader.Read()
    : at System.Data.Common.DbDataAdapter.FillLoadDataRow(SchemaMapping mapping)
    : at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
    : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
    : at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    : at WindowsApplication1.Form1.textBox1_Leave(Object sender, EventArgs e) in c:projectsvb-netwindowsapplication1form1.cs:line 139
    : at System.Windows.Forms.Control.OnLeave(EventArgs e)
    : at System.Windows.Forms.Control.NotifyLeave()
    : at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
    :
    :
    : ************** Loaded Assemblies **************
    : mscorlib
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
    : ----------------------------------------
    : WindowsApplication1
    : Assembly Version: 1.0.1782.31783
    : Win32 Version: 1.0.1782.31783
    : CodeBase: file:///c:/projects/vb-net/WindowsApplication1/bin/Debug/WindowsApplication1.exe
    : ----------------------------------------
    : System.Windows.Forms
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    : ----------------------------------------
    : System
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    : ----------------------------------------
    : System.Drawing
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    : ----------------------------------------
    : System.Data
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
    : ----------------------------------------
    : System.Xml
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    : ----------------------------------------
    : System.EnterpriseServices
    : Assembly Version: 1.0.5000.0
    : Win32 Version: 1.1.4322.2032
    : CodeBase: file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
    : ----------------------------------------
    :
    : ************** JIT Debugging **************
    : To enable just in time (JIT) debugging, the config file for this
    : application or machine (machine.config) must have the
    : jitDebugging value set in the system.windows.forms section.
    : The application must also be compiled with debugging
    : enabled.
    :
    : For example:
    :
    :
    :
    :
    :
    : When JIT debugging is enabled, any unhandled exception
    : will be sent to the JIT debugger registered on the machine
    : rather than being handled by this dialog.
    :
    :
    : thanks,
    :
    : naitek
    :

  • naiteknaitek Posts: 2Member
    : How do you suggest i fix this problem ?
    long @Param2 = int.Parse(txtIn.Text);
    string sqlCommand = "Select * from SCCalls Where callnumber = " + @Param2;

    da = new SqlDataAdapter(sqlCommand, this.conn);

    da.Fill(dataSet11, "SCCalls");
    DataTable dataTable = new DataTable();

    foreach(DataRow dr in dataTable.Rows)
    {
    lbOut.Items.Add(dr["CallNumber"]);
    }
    here is the code. I know it is something simple, but i just don't know what.

    thanks

    naitek

    : It would seem to me that one of the columns in the data set is configured to hold int objects, while the column it is mapped to in the database is not ('`' is not an int).
    :
    : : Hello All,
    : :
    : : Any help besides changing the database information would be awesome as I can't seem to find help anywhere else.
    : :
    : : Here is the debug info:
    : :
    : :
    : : ************** Exception Text **************
    : : System.Data.SqlClient.SqlException: Syntax error converting the varchar value '`' to a column of data type int.
    : : at System.Data.SqlClient.SqlDataReader.Read()
    : : at System.Data.Common.DbDataAdapter.FillLoadDataRow(SchemaMapping mapping)
    : : at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
    : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
    : : at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    : : at WindowsApplication1.Form1.textBox1_Leave(Object sender, EventArgs e) in c:projectsvb-netwindowsapplication1form1.cs:line 139
    : : at System.Windows.Forms.Control.OnLeave(EventArgs e)
    : : at System.Windows.Forms.Control.NotifyLeave()
    : : at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
    : :
    : :
    : : ************** Loaded Assemblies **************
    : : mscorlib
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
    : : ----------------------------------------
    : : WindowsApplication1
    : : Assembly Version: 1.0.1782.31783
    : : Win32 Version: 1.0.1782.31783
    : : CodeBase: file:///c:/projects/vb-net/WindowsApplication1/bin/Debug/WindowsApplication1.exe
    : : ----------------------------------------
    : : System.Windows.Forms
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    : : ----------------------------------------
    : : System
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    : : ----------------------------------------
    : : System.Drawing
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    : : ----------------------------------------
    : : System.Data
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
    : : ----------------------------------------
    : : System.Xml
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    : : ----------------------------------------
    : : System.EnterpriseServices
    : : Assembly Version: 1.0.5000.0
    : : Win32 Version: 1.1.4322.2032
    : : CodeBase: file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
    : : ----------------------------------------
    : :
    : : ************** JIT Debugging **************
    : : To enable just in time (JIT) debugging, the config file for this
    : : application or machine (machine.config) must have the
    : : jitDebugging value set in the system.windows.forms section.
    : : The application must also be compiled with debugging
    : : enabled.
    : :
    : : For example:
    : :
    : :
    : :
    : :
    : :
    : : When JIT debugging is enabled, any unhandled exception
    : : will be sent to the JIT debugger registered on the machine
    : : rather than being handled by this dialog.
    : :
    : :
    : : thanks,
    : :
    : : naitek
    : :
    :
    :

  • BaldusariusBaldusarius Posts: 162Member
    The exception's message makes me think the problem is how the dataset is defined being different from the database's structure. You haven't posted that part of the code, so I can't say for sure, however.

    There are other curiosities in the code you posted, though. Here are a couple improvements that could be made:

    int.Parse will throw a FormatException if the string passed to it cannot be converted, so your code will break if txtIn.Text contains any non-integer characters. (You may validate this elsewhere, in which case you're good to go)

    You should really be using parameterized queries instead of using concatenation to build SQL queries. Your liability is somewhat limited here because you only have one numeric variable, but using concatenation should generally be avoided.

    You have -

    DataTable dataTable = new DataTable();

    foreach(DataRow dr in dataTable.Rows)...

    Is this the actual code? The code in the foreach never executes because it's a new data table.

    : : How do you suggest i fix this problem ?
    : long @Param2 = int.Parse(txtIn.Text);
    : string sqlCommand = "Select * from SCCalls Where callnumber = " + @Param2;
    :
    : da = new SqlDataAdapter(sqlCommand, this.conn);
    :
    : da.Fill(dataSet11, "SCCalls");
    : DataTable dataTable = new DataTable();
    :
    : foreach(DataRow dr in dataTable.Rows)
    : {
    : lbOut.Items.Add(dr["CallNumber"]);
    : }
    : here is the code. I know it is something simple, but i just don't know what.
    :
    : thanks
    :
    : naitek
    :
    : : It would seem to me that one of the columns in the data set is configured to hold int objects, while the column it is mapped to in the database is not ('`' is not an int).
    : :
    : : : Hello All,
    : : :
    : : : Any help besides changing the database information would be awesome as I can't seem to find help anywhere else.
    : : :
    : : : Here is the debug info:
    : : :
    : : :
    : : : ************** Exception Text **************
    : : : System.Data.SqlClient.SqlException: Syntax error converting the varchar value '`' to a column of data type int.
    : : : at System.Data.SqlClient.SqlDataReader.Read()
    : : : at System.Data.Common.DbDataAdapter.FillLoadDataRow(SchemaMapping mapping)
    : : : at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
    : : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
    : : : at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    : : : at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    : : : at WindowsApplication1.Form1.textBox1_Leave(Object sender, EventArgs e) in c:projectsvb-netwindowsapplication1form1.cs:line 139
    : : : at System.Windows.Forms.Control.OnLeave(EventArgs e)
    : : : at System.Windows.Forms.Control.NotifyLeave()
    : : : at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
    : : :
    : : :
    : : : ************** Loaded Assemblies **************
    : : : mscorlib
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
    : : : ----------------------------------------
    : : : WindowsApplication1
    : : : Assembly Version: 1.0.1782.31783
    : : : Win32 Version: 1.0.1782.31783
    : : : CodeBase: file:///c:/projects/vb-net/WindowsApplication1/bin/Debug/WindowsApplication1.exe
    : : : ----------------------------------------
    : : : System.Windows.Forms
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    : : : ----------------------------------------
    : : : System
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    : : : ----------------------------------------
    : : : System.Drawing
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    : : : ----------------------------------------
    : : : System.Data
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
    : : : ----------------------------------------
    : : : System.Xml
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    : : : ----------------------------------------
    : : : System.EnterpriseServices
    : : : Assembly Version: 1.0.5000.0
    : : : Win32 Version: 1.1.4322.2032
    : : : CodeBase: file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
    : : : ----------------------------------------
    : : :
    : : : ************** JIT Debugging **************
    : : : To enable just in time (JIT) debugging, the config file for this
    : : : application or machine (machine.config) must have the
    : : : jitDebugging value set in the system.windows.forms section.
    : : : The application must also be compiled with debugging
    : : : enabled.
    : : :
    : : : For example:
    : : :
    : : :
    : : :
    : : :
    : : :
    : : : When JIT debugging is enabled, any unhandled exception
    : : : will be sent to the JIT debugger registered on the machine
    : : : rather than being handled by this dialog.
    : : :
    : : :
    : : : thanks,
    : : :
    : : : naitek
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.