fill combobox using sproc and variable

DimMeAsLost

Active member
Joined
Jan 31, 2010
Messages
29
Programming Experience
1-3
Hello all.

I have created a dialog form with a combo box, it has an OK and Cancel button. It is called frmEstSel.

I have a stored procedure that has 1 input parameter (@Branch). The data for the parameter is in a global variable at 'modUser.ThisAppUser.Branch'.

What I need is to connect to server, pass parameter, load the combo box. Second, I will need to pass the item selected in the combo box to a second stored procedure (@EstName is parameter for second sproc) and open a form to display that record.

90% of my application I am creating will use this method, so I am anxious to learn so it can be repeated.

Thanks in advance
 
If I copy this code to the form load event, pass the variable to the fill textbox, and then hide the toolstrip, It will work. I actually have it working. Now, is this the best practice?
 
Delete the toolstrip if you don't need it. Remove all the underlaying code.

On your form load event
VB.NET:
Try
            Me.SpOpenEstimateTableAdapter.Fill(Me.MT3ds.spOpenEstimate, vJob)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
As long as vJob is the name of your global variable your global variable!

You could rename the query on the dataTable, so that it matches what you are doing. For instance:
.Fill - fills EVERY row
.FillByJobID - fills by a variable JobID
.FillByCustomerID - fills by a variable CustomerID
etc etc

You can have more than one query on a dataTable. By default it's call it .Fill . This can and will get confusing the more queries you put on the dataTable.

Personally, the way you've now got this working is the same way that I do things (except I don't really use stored procedures, just SQL queries)
 
Thanks for your help. Very much appreciated.

Stored Procedures is a must on my application. SQL server is going to be a hosted SQL Server. Trying to be super efficient on the data transfer.

Thanks again.
 
Back
Top