|
-
Oct 3rd, 2000, 10:23 AM
#1
Thread Starter
Hyperactive Member
Connected to a database using the following code:
Set dbase = Workspaces(0).OpenDatabase(globaldir + "diary")
This connects fine. I can then select some values from this database and one of the tables by doing the following:
sqlstring = "SELECT * FROM tbldescrip"
Set rs = dbase.OpenRecordset(sqlstring, dbOpenDynaset)
and this works fine. The problem occurs when I try to use the insert into sql function.
I'm currently doing the following:
sqlstring = "INSERT INTO tbldescrip VALUES ('1st value', '2nd value', '3rd value', '4th value')"
Set rs = dbase.OpenRecordset(sqlstring, dbOpenDynaset)
and I'm told that it's an invalid operation. I've tested all my rights, and columns in my database, and they are fine.
Please help.
-
Oct 3rd, 2000, 10:39 AM
#2
Addicted Member
Instead of using Recordset, use command
-
Oct 3rd, 2000, 10:42 AM
#3
Thread Starter
Hyperactive Member
there is no command from what i can see in the vb auto complete drop down list.
-
Oct 3rd, 2000, 10:52 AM
#4
Member
Rives,
richy is using DAO there is no command object there.
richy,
I've never tried using it like that. Why don't you try the following after opening the recordset with either a SELECT statement of just the table name:
Recordset.AddNew
Recordset.Fields("Field1") = Value1
Recordset.Fields("Field2") = Value2 etc....
Recordset.Update
Hope this helps.
Barend
JHB-SA
Nothing is impossible, except skiing through a revolving door.
-
Oct 3rd, 2000, 10:55 AM
#5
Thread Starter
Hyperactive Member
the reason is that we are making it faster and running it completely through code rather than using the actual control. To do the code that you see above, you don't even use the data control.
-
Oct 3rd, 2000, 01:19 PM
#6
Junior Member
re SQL Database Problem
Try using the execute method like so
dbase.execute sqlstring
Ciao.........Gary
VB6, SQL Server 7, Access 97
-
Oct 4th, 2000, 03:20 AM
#7
Thread Starter
Hyperactive Member
Cheers for everyones help.
I suddenly realised when reading Gary Juleffs post that you can't set a recordset to an insert statement, so in other words the line went from:
Set rs = dbase.OpenRecordset(sqlstring, dbOpenDynaset)
to
dbase.OpenRecordset(sqlstring, dbOpenDynaset)
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
|