Questions on Convert.ToInt for ODBC Command

jsscott

New member
Joined
Apr 7, 2005
Messages
2
I am using the code below (one of way too many samples) trying to accept strings from form and pass them to ODBC connect query. No matter which way I twist it, I always get a Format exception error.
I can not get the input string to accept the three parameters in the correct format.
Any ideas?

Private Sub btn_search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_search.Click

Dim p_tax_year As Integer = Convert.ToInt32(cbx_tax_year.SelectedText)
Dim p_taxpayer_doc_num As Integer = Convert.ToInt32(tb_taxpayer_document_nm.Text)
Dim p_taxpayer_ssn As Integer = Convert.ToInt32(tbx_taxpayer_ssn.Text)
Dim OdbcDataAdapter_all_forms_list As DataSet_all_forms_list
OdbcConnection2.Open()

Add Parameters and set values
listSelectCmd.Parameters.Clear()
listSelectCmd.Parameters.Add(p_tax_year)
listSelectCmd.Parameters.Add(p_taxpayer_doc_num)
listSelectCmd.Parameters.Add(p_taxpayer_ssn)

Dim DataSet_all_forms_list1 As DataSet = New DataSet
Dim TAXPAYER As DataTable = DataSet_all_forms_list1.Tables("TAXPAYER")
Try
listSelectCmd.ExecuteNonQuery()
Catch SqlExceptionErr As SyntaxErrorException
MessageBox.Show(SqlExceptionErr.Message)
End Try
OdbcConnection2.Close()
End Sub
 
PlausiblyDamp said:
What are the text values you are trying to convert to integers?

They are a year written as a four digit number, a social security number written as a nine digit number, or a document number written as an eleven digit number.
I kept them as numbers as that is our standard for these fields. I am using ODBC because this will eventually go against an oracle database (not the Access one I am testing against) and I do not want to have to rewrite everything.

I do not think the problem comes from the conversion or the fields themselves, I think it comes from the passing of the values to the parameters.
I can find no good documentation on how to do this for ODBC.
 
Back
Top