Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Go Back  Xtreme Visual Basic Talk > > > Error while passing access database values into vb.net dataset


Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2008, 01:50 AM
xcorpionxting xcorpionxting is offline
Newcomer
 
Join Date: Jul 2008
Posts: 23
Question Error while passing access database values into vb.net dataset


Trying to make a vb.net program that is able to read values from an access database and pass them into some data sets. Here is the code I have so far, with the error line between the two dotted lines:
Code:
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim cnnOLEDB As New OleDbConnection
    Dim cmdOLEDB As New OleDbCommand
    Dim cmdInsertDP11 As New OleDbCommand
    Dim cmdInsertIncomeTax As New OleDbCommand
    Dim cmdInsertDP11a As New OleDbCommand
    Dim cmdInsertIMM55 As New OleDbCommand
    Dim cmdInsertIMM12 As New OleDbCommand
    Dim cmdInsertEmployerFH As New OleDbCommand
    Dim cmdUpdate As New OleDbCommand
    Dim cmdSelect As New OleDbCommand
    Dim cmdDelete As New OleDbCommand
    Dim strEmpty As String = " "
    Dim dt As String = Format(Date.Today, "dd/MM/yyyy")

    Private Sub btnTester_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillBatchName.Click
        Dim strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ImmigrationSystem.mdb"

        cnnOLEDB.ConnectionString = strConnectionString
        cnnOLEDB.Open()

        Dim da As New OleDb.OleDbDataAdapter("select batchName from recordImmigration", strConnectionString)
        Dim ds As New DataSet
        da.Fill(ds)

        For i = 0 To ds.Tables(0).Rows.Count - 1
            CheckedListBox1.Items.Add(ds.Tables(0).Rows(i)(0))
        Next i
        cnnOLEDB.Close()
    End Sub

    Private Sub btnExport2List_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport2List.Click

        Dim xId As String = " "
        Dim xBatchId As String = " "
        Dim xBatchName As String = " "


        For Each o In CheckedListBox1.CheckedItems

            Dim strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ImmigrationSystem.mdb"
            cnnOLEDB.ConnectionString = strConnectionString

            Dim da_Id As New OleDb.OleDbDataAdapter("select Id from recordImmigration WHERE batchName =('" & o.ToString() & "')", strConnectionString)
            Dim ds_Id As New DataSet
            da_Id.Fill(ds_Id)
            For i = 0 To ds_Id.Tables(0).Rows.Count - 1
                xId = ds_Id.Tables(0).Rows(i)(0)
                strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ImmigrationSystem.mdb"
                cnnOLEDB.ConnectionString = strConnectionString
                Dim da_xBatchId As New OleDb.OleDbDataAdapter("select batchID from recordImmigration WHERE Id =('" & xId.ToString() & "')", strConnectionString)
                Dim ds_xBatchId As New DataSet
''---------------------------------------------------------------
                da_xBatchId.Fill(ds_xBatchId)
''---------------------------------------------------------------
                xBatchId = ds_xBatchId.Tables(0).Rows(i)(0)
            Next i
End Sub
End Class
Basically, the program passes batch names into a checked list box, then after checking some boxes the program reads the Id and the BatchId of the checked batch names (to send them to xml later). Strangely, althought the same commands are used to read both xId and xBatchId are the same, its only working for xId. I keep getting the error : "OleDbExeption was unhandled. Data type mismatch in criteria expression." What did I miss? Thanks.
Reply With Quote
  #2  
Old 09-23-2008, 08:40 AM
morbidangel morbidangel is offline
Regular
 
Join Date: Apr 2005
Posts: 91
Default

Code:
Dim da_xBatchId As New OleDb.OleDbDataAdapter("select batchID from recordImmigration WHERE Id =(" & xId.ToString() & ")", strConnectionString)

If the field Id is numeric, you must not surround it with apostrophes
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
 
Error while passing access database values into vb.net dataset
Error while passing access database values into vb.net dataset
 
-->