The attached code has a database to go with it. The combo box is not able to get filled with the necessary information.
Error: A first chance exception of type 'System.Data.SqlClient.Sql
occurred in System.Data.dll
Question: How can I correct my code to make this work?
I couldn't upload the application, perhaps I could email it to you if you send an email to my user id at hotmail. Or, if you know a way so I can get rid of the objectionable extensions such as .exe, sou. etc so I can upload it here.
Public Class frmCustomer
Dim conWS As New SqlConnection()
Dim conStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WSCGSoftware.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim selectCommand As SqlCommand
'Dim selectStatement As String
Private Sub frmCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conWS.ConnectionString = conStr
'selectStatement = "SELECT CustomerID, FirstName + ' ' + LastName As Costomer FROM tblCustomers ORDER BY Name;"
'selectCommand.CommandText = selectStatement
Get_CustomerIDs() 'populate comboBox
Private Sub Get_CustomerIDs()
Dim rdr As SqlDataReader
Dim cmd As New SqlCommand("SELECT CustomerID, FirstName + ' ' + LastName As Costomer FROM tblCustomers ORDER BY Name;")
cmd.Connection = conWS
rdr = cmd.ExecuteReader()
Dim dt As New DataTable
Me.cobSelectCust.DataSource = dt
Me.cobSelectCust.DisplayMember = "Costomer"
Me.cobSelectCust.ValueMember = "CustomerID"