Strange Data Parameter Problem

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hello:

Ok I have two code samples here. This one doesn't work at all.

The error is
Input string was not in a correct format.


daClientsMain.SelectCommand.Parameters("ClientID").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("OfficeFileNum").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("MortPolNum").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("FeePolNum").Value
= txtFind.Text

Dim MyCheck As Boolean
MyCheck = IsDate(txtFind.Text)
If MyCheck = True Then
daClientsMain.SelectCommand.Parameters("ClosingDate").Value
= CDate(txtFind.Text)
Else
daClientsMain.SelectCommand.Parameters("ClosingDate").Value
= CDate(#2/2/1902#)
End If

daClientsMain.SelectCommand.Parameters("BuyerSearchCode").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("SellerSearchCode").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("PropertyAddress").Value
= txtFind.Text
Me.daClientsMain.Fill(objdsClients)


But this one does work as long as I type in a valide date into txtFind.Text:



daClientsMain.SelectCommand.Parameters("ClientID").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("OfficeFileNum").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("MortPolNum").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("FeePolNum").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("ClosingDate").Value
= CDate(txtFind.Text)
daClientsMain.SelectCommand.Parameters("BuyerSearchCode").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("SellerSearchCode").Value
= txtFind.Text
daClientsMain.SelectCommand.Parameters("PropertyAddress").Value
= txtFind.Text
Me.daClientsMain.Fill(objdsClients)


I can type in any date format into it and it works ie 5/5/05 or 5/5/2005 or
05/05/05 or 05/05/2005 or May 5, 2005 all work in the second sample..


TIA

Bob
 
no but it works if I change

daClientsMain.SelectCommand.Parameters("ClientID").Value = txtFind.Text

to

daClientsMain.SelectCommand.Parameters("ClientID").Value = 0

but not if I change it to

daClientsMain.SelectCommand.Parameters("ClientID").Value =
CInt(txtFind.Text)

I see I need to write some err handling

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top