Hello again

Please your support with the next statement in vb.net and access database
this is part of the code can you help me
the error code is missing operator in query expression

            str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\MXDTBTZ3XC1\Users\MXDTBTZ3XC1\Desktop\refacciones web\surtido.accdb"
            con = New OleDbConnection(str)
            sql = "select * from material where IDDOS ='" & TextBox10.Text & "' AND MATERIAL ACEPTABLE = '" & TextBox14.Text & "'"
1 Year
Discussion Span
Last Post by pezzinae

It's never a good idea to use spaces in field names. If you do then you have to use delimiters around the field name. If possible you should rename the field and code something like

sql = "select * from material where IDDOS ='" & TextBox10.Text & "' AND MATERIAL_ACEPTABLE = '" & TextBox14.Text & "'"

Access may be the same as MS-SQL in which case you could code

sql = "select * from material where IDDOS ='" & TextBox10.Text & "' AND [MATERIAL ACEPTABLE] = '" & TextBox14.Text & "'"

If that doesn't work you'll have to look up the correct delmiter for Access.

Edited by Reverend Jim


Hello Reverend Jim

the operator "AND" throws me an error please check my code I´ve made a modification
in my database
"Conversion from string to type Long is not valid"
I believe my statement is not the right one for achieve what i want

I share the part of code that have the issue

        str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\MXDTBTZ3XC1\Users\MXDTBTZ3XC1\Desktop\refacciones web\inventarioreal.accdb"
        con = New OleDbConnection(str)
        sql = "select * from inventario where numero_de_parte ='" & TextBox2.Text & "'" And "MATERIAL_ACEPTABLE = '" & TextBox14.Text & "'"

Hello it´s resovled

it was just an apostrophe damn!!!!

I hate when this kind of things happen, something that is just that easy and dificult to see
thanks Reverend Jim

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.