Ok, been tinkering around. I have this code below, that when the dialog form with the combo box (frmSelEst2) loads then the combobox is populated from the stored proc with the parameter being sent. This works great, but I need someone to check if anything is bad or needs to be changed to make it more efficient. I also need to add error handling. I have not come to grips with 'Try...Finally' yet. Still learning.
Code:Private Sub frmSelEst2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con1 As New SqlClient.SqlConnection("Data Source=CompDEV;Initial Catalog=XXXX;Persist Security Info=True;User ID=sa;Password=XXXX") Dim dtSelEst As New DataTable("Jobs") If Not con1.State = ConnectionState.Open Then con1.Open() Dim mjsqlcmd As New SqlClient.SqlCommand("spSelEst1", con1) mjsqlcmd.CommandType = CommandType.StoredProcedure mjsqlcmd.Parameters.Add("@prmBidOff", SqlDbType.NVarChar, 50) mjsqlcmd.Parameters("@prmBidOff").Value = modUser.ThisAppUser.AceBranch dtSelEst.Load(mjsqlcmd.ExecuteReader()) With cboJobs .DataSource = dtSelEst .ValueMember = "JobName" .DisplayMember = "JobName" End With con1.Close() End Sub
Thanks again for any suggestions.



LinkBack URL
About LinkBacks




Reply With Quote

Bookmarks