|
-
Dec 1st, 2003, 10:51 AM
#1
Thread Starter
Fanatic Member
Data deleted
I have one adodc control and one combo box. The adodc is setup to connect to a sql server using this select statement
"Select Last_Name, First_Name from Persdata"
(Persdata is the table).
The combo box is setup with datasource as adodc1 and the datafield as Last_Name.
The only other code I have is on form load and it is
Private Sub Form_Load()
Dim record As Variant
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
record = Adodc1.Recordset.Fields("Last_Name").Value
If record <> "" Then
Combo1.AddItem record
End If
Adodc1.Recordset.MoveNext
Loop
End Sub
The first time run, it populates the drop down of the combo with all Last_Names in the table. After I close and run a second time, the combo box is empty. I go and check the SQL table and the complete Last_Name column is now empty. I have been trying for 2 weeks now to be able to get a combo box that will list a field out of a sql table. I know some will say use a connect string which I have tried but I have never gotten that to work either. I would be more than willing to give someone all the info required to write a connect string but I also know people arent here to write my code but I am either too new or too stupid to figure this out. Help me please.
-
Dec 1st, 2003, 11:12 AM
#2
You have a combobox bound to a datacontrol and yet you are loading the combobox manually. Its either one or the other.
Everytime you do a MoveNext, the recordset checks if it needs to do an Update. Since your control is bound to the combobox and the combobox has no current item (ie the ComboBox.Text property = ''"), the recordset thinks you have changed the data and automatically saves the changes.
-
Dec 1st, 2003, 11:29 AM
#3
Thread Starter
Fanatic Member
so what I need then is to drop the datasource of the combo box? I did that and now it has a Object variable or With block variable not set (Error 91)
Or should I be trying to get the connection working, if so can anyone write me a connection for this.
SQL server: KG-CFSCE-2B
Trusted Connection
Database: TrainingManagementDB2
Table: Persdata
Field: Last_Name (if Needed)
I know I should write my own code and I have been trying for the past 2 weeks to get this to work. I have seen many examples and tried 10 or so different methods but the only way I have been able to connect is with the adodc. I would prefer to learn the connection.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|