Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...