Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding from a dataset to a textbox

Status
Not open for further replies.

jimbledon

Technical User
Dec 27, 2004
22
GB
Hi All,

I'm in the process of build a small mobile application (applogies if this post is the wrong area)
When binding a textbox to a table in the dataset i get a
Code:
"System Argument Exception: Argument Exception"
This is strange as i can bind the dataset to a datagrid or a combobox with no problem.

Does anyone know if there is a limitation in the compact framework that doesnt allow this?

The code for this is
Code:
Try
      Dim StrMsg As String
      StrMsg = "Add New Estimate for :" & ComboBox1.Text
      Dim response As MsgBoxResult

      response = MsgBox(StrMsg, MsgBoxStyle.YesNo)

      If response = MsgBoxResult.No Then

        'MsgBox("Add New Customer")

        ' create the dataadapter, and add to the dataset
        Dim strSelectCustomers As String = "SELECT CustId, CustSName, CustFName, CustPhone1, CustPhone2, CustFax, CustMemo FROM TblCustTable"

        Dim strConnString As String = "data source=192.168.1.200;database=Project;integrated security=SSPI;User ID=IUSR_PAUL-56F7AB7IHO;Password=password"

        ' Using the connection object
        Dim connProject As New SqlClient.SqlConnection
        connProject.ConnectionString = strConnString

        'Dim cmdCustomers As New SqlCommand(strSelectCustomers, connProject)
        Dim daAddCustomer As SqlDataAdapter
        'Dim workTable As DataTable = New DataTable("TblCustTable")

        connProject.Open()
        daAddCustomer = New SqlDataAdapter(strSelectCustomers, connProject)

        Dim StrState As String

        daAddCustomer.Fill(dsCustomers, "TblCustTable")
       

        ' bind the controls to test the dataset
        With ComboBox1
          .DataSource = dsCustomers.Tables("TblCustTable")
          .DisplayMember = "CustFName"
          .ValueMember = "CustId"

        End With

       
        TxtCustFName.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustFName"))
         TxtCustSName.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustSName"))
         TxtCustPhone1.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustPhone1"))
         TxtCustPhone2.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustPhone2"))
         TxtCustFax.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustFax"))
         TxtMemo.DataBindings.Add(New Binding("Text", dsCustomers, "TblCustTable.CustMemo"))
        connProject.Close()
        'show the controls
        showControls()
' add new record
        BindingContext(dsCustomers, "TblCustTable").AddNew()

      Else
        MsgBox("Take Combo Value and add new estimate")
      End If
    Catch excNull As Exception

      MsgBox("3: " & excNull.GetBaseException.ToString())
      'Console.WriteLine(excNull.InnerException)

Many Thanks

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top