locked
Data Type Mistmatch RRS feed

  • Question

  • User-659728574 posted

    Hi im having issues getting a report with the error of data type mistmatch.

    Here are my fields in the database.

    COMPANY_NAME = TEXT

    INVOICE_DATE = DATETIME (mm/dd/yyyy)

    My fields are in an access database then i trying tio Parse the variables like this

    Protected Sub Button1_Click(sender As Object, e As EventArgs)


    Dim company As String = ddlCOMPANY_name.SelectedValue
    Dim bdate = txtBdate.Text
    Dim edate  = txtEnddate.Text
    Dim dt As DataTable = New DataTable
    Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=|DataDirectory|NOVABRO1.accdb"
    Using con As New OleDbConnection(strConnString)

    Dim strQuery As String = "SELECT SUM(SKIDS) AS XRESULT FROM NEWRECEIVE INNER JOIN NEWITEM ON NEWRECEIVE.WO = NEWITEM.WO WHERE NEWRECEIVE.[COMPANY_NAME]='" & company.ToString & "' AND NEWRECEIVE.[INVOICE_DATE]>='" + DateAndTime.DateValue(bdate) + "' AND NEWRECEIVE.[INVOICE_DATE]<='" + DateAndTime.DateValue(edate) + "'"

    this is what i get on cmd after input data

    "SELECT SUM(SKIDS) AS XRESULT FROM NEWRECEIVE INNER JOIN NEWITEM ON NEWRECEIVE.WO = NEWITEM.WO WHERE NEWRECEIVE.[COMPANY_NAME]='AMEREX' AND NEWRECEIVE.[INVOICE_DATE]>='1/10/2014' AND NEWRECEIVE.[INVOICE_DATE]<='1/10/2014'"

    Using cmd As New OleDbCommand(strQuery, con)
    Dim sda As OleDbDataAdapter = New OleDbDataAdapter
    cmd.Connection = con
    con.Open()
    sda.SelectCommand = cmd
    sda.Fill(dt)  <-----------heres is where i getting the error....

    but still having the same error DATA TYPE MISTMATCH

    any help will be appreciated.

    thanks

    Thursday, January 30, 2014 11:23 AM

Answers