ODBC, ADO
-
Hi, I'd created a database using SQL Server. Then I've created ODBC in the control panel. I want to know :confused: how I can deal with ODBC in VB6. I've tried to use "Adodc" but I think it saves just one record. I’ve used this statement"Adodc.Recordset.AddNew" , but it saved the new record and deleted the old one. Also I want to be able to save whatever I want in the fields without using DataField property for TextBoxes. Or, I wonder if I could use Data Control with ODBC. I've used these statments: Data1.Connect = "DSN=DSNName" Data1.RecordSource = "My TableName" But seems that it needs to SET recordset. What should I use for it? Thanks.
-
Hi, I'd created a database using SQL Server. Then I've created ODBC in the control panel. I want to know :confused: how I can deal with ODBC in VB6. I've tried to use "Adodc" but I think it saves just one record. I’ve used this statement"Adodc.Recordset.AddNew" , but it saved the new record and deleted the old one. Also I want to be able to save whatever I want in the fields without using DataField property for TextBoxes. Or, I wonder if I could use Data Control with ODBC. I've used these statments: Data1.Connect = "DSN=DSNName" Data1.RecordSource = "My TableName" But seems that it needs to SET recordset. What should I use for it? Thanks.
If you dont want to use the DataField and DataMember properties, it is best to just use ADO code.
Dim conn As ADODB.Connection
Dim rs as ADODB.Recordset
Set conn = new Connection
conn.Open "DSN=DSNName"
set rs = conn.Execute("SELECT * FROM table")etc. etc. -- David Wengier Sonork ID: 100.14177 - Ch00k
-
If you dont want to use the DataField and DataMember properties, it is best to just use ADO code.
Dim conn As ADODB.Connection
Dim rs as ADODB.Recordset
Set conn = new Connection
conn.Open "DSN=DSNName"
set rs = conn.Execute("SELECT * FROM table")etc. etc. -- David Wengier Sonork ID: 100.14177 - Ch00k
-
Thanks:rose: for the replaying but I want to Add , Delete or Edit the Data :confused: . When I used "rs.addnew" it gives me an error.
You can add, update and delete using SQL statements as I have said. If you notice the error message would probably have said something about having the wrong cursor type to use AddNew. Therefore, open the recordset using a different cursor. Try Dynamic. -- David Wengier Sonork ID: 100.14177 - Ch00k
-
You can add, update and delete using SQL statements as I have said. If you notice the error message would probably have said something about having the wrong cursor type to use AddNew. Therefore, open the recordset using a different cursor. Try Dynamic. -- David Wengier Sonork ID: 100.14177 - Ch00k