NickySummers
New Member
- Joined
- Jul 25, 2014
- Messages
- 1
Hi,
I've have the code below to fill a combobox with data from a mySQL stored procedure. The SP selects the customer code and customer name. Depending on what customer code the user chooses, I need to populate a textbox with the associated customer name. Please could somebody help me with the best way to do this?
Thanks very much.
Dim Conn As ADODB.Connection
Dim ConnectionString As String
Dim cmd As ADODB.Command
Dim fld As Variant
Dim Results As ADODB.Recordset
Dim x As Integer
Dim vaData As Variant
'ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=TestVSQL01\TestSQL01;Database=OptimusBridge;Uid=delta_web_test;Pwd=delta_web_test"
ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=BI-BRIDGE\SQLExpress;Database=OptimusBridge;Uid=workstream;Pwd=workstream"
Set Conn = New ADODB.Connection
Conn.Open ConnectionString
Set cmd = New ADODB.Command
With cmd
.CommandText = "GetAllClients"
.CommandType = adCmdStoredProc
.ActiveConnection = Conn
End With
Set Results = cmd.Execute
With Results
x = .Fields.Count
vaData = .GetRows
End With
With frmDataInput
With .cboClient
.BoundColumn = x
.List = Application.Transpose(vaData)
.ListIndex = -1
End With
.Show vbModeless
End With
Results.Close
Set Results = Nothing
I've have the code below to fill a combobox with data from a mySQL stored procedure. The SP selects the customer code and customer name. Depending on what customer code the user chooses, I need to populate a textbox with the associated customer name. Please could somebody help me with the best way to do this?
Thanks very much.
Dim Conn As ADODB.Connection
Dim ConnectionString As String
Dim cmd As ADODB.Command
Dim fld As Variant
Dim Results As ADODB.Recordset
Dim x As Integer
Dim vaData As Variant
'ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=TestVSQL01\TestSQL01;Database=OptimusBridge;Uid=delta_web_test;Pwd=delta_web_test"
ConnectionString = "Provider=MSDASQL.1;Driver={SQL Server};Server=BI-BRIDGE\SQLExpress;Database=OptimusBridge;Uid=workstream;Pwd=workstream"
Set Conn = New ADODB.Connection
Conn.Open ConnectionString
Set cmd = New ADODB.Command
With cmd
.CommandText = "GetAllClients"
.CommandType = adCmdStoredProc
.ActiveConnection = Conn
End With
Set Results = cmd.Execute
With Results
x = .Fields.Count
vaData = .GetRows
End With
With frmDataInput
With .cboClient
.BoundColumn = x
.List = Application.Transpose(vaData)
.ListIndex = -1
End With
.Show vbModeless
End With
Results.Close
Set Results = Nothing