L
Loic
HI there, I hope someone can help.
I am doing this application on a pocket pc where you type a product
number and it returns several values that are taken from an sqlce
database.
What happens is that when I click the Search button the first time it
returns the values from the database alright, but the second time it
returns an Argument Exception error. I think it is the textbox
databinding that I am not doing right, because if I rem out the line
there is no error.
See simplified code below. I have hardcoded the productnumber.
Thanks in advance for any help
Loic
Imports System
Imports System.Windows.Forms
Imports System.Data.SqlServerCe
Imports System.IO
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Dim cn As SqlCeConnection
Dim barcode As String
Try
barcode = TextBox1.Text
cn = New SqlCeConnection("data source=\Storage
Card\FinalCe.sdf;SSCE:database Password=")
cn.Open()
Dim da As New SqlCeDataAdapter("select sku from salesce
where autoitemno=243429", cn)
Dim ds As New DataSet
da.Fill(ds)
TextBox2.Enabled = False
TextBox2.DataBindings.Add("Text", ds.Tables(0), "sku")
Catch sqlex As SqlCeException
Dim SqlError As SqlCeError
For Each SqlError In sqlex.Errors
MessageBox.Show(SqlError.Message)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
TextBox2.Enabled = True
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End Try
End Sub
I am doing this application on a pocket pc where you type a product
number and it returns several values that are taken from an sqlce
database.
What happens is that when I click the Search button the first time it
returns the values from the database alright, but the second time it
returns an Argument Exception error. I think it is the textbox
databinding that I am not doing right, because if I rem out the line
there is no error.
See simplified code below. I have hardcoded the productnumber.
Thanks in advance for any help
Loic
Imports System
Imports System.Windows.Forms
Imports System.Data.SqlServerCe
Imports System.IO
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Dim cn As SqlCeConnection
Dim barcode As String
Try
barcode = TextBox1.Text
cn = New SqlCeConnection("data source=\Storage
Card\FinalCe.sdf;SSCE:database Password=")
cn.Open()
Dim da As New SqlCeDataAdapter("select sku from salesce
where autoitemno=243429", cn)
Dim ds As New DataSet
da.Fill(ds)
TextBox2.Enabled = False
TextBox2.DataBindings.Add("Text", ds.Tables(0), "sku")
Catch sqlex As SqlCeException
Dim SqlError As SqlCeError
For Each SqlError In sqlex.Errors
MessageBox.Show(SqlError.Message)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
TextBox2.Enabled = True
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End Try
End Sub