|
-
Apr 15th, 2007, 03:46 AM
#1
Thread Starter
New Member
Not inserting into DB
Hello,
First of all I am using VB 6 and the Visual Data Manager to create the database.
I have the following line of code :
plotadder.RecordSource = "INSERT INTO Plot (Title, Agent_id, Location, Price, Type, Bedrooms, Bathrooms, FloorArea, Description, photo, builton) values('" & txttitle.Text & "'," & txtagentid.Text & ",'" & txtlocation.Text & "'," & txtprice.Text & ",'" & cmbtype.Text & "'," & cmbbathrooms.Text & "," & cmbbedrooms.Text & "," & txtfloorarea.Text & ",'" & txtdescription.Text & "','" & App.Path & "\photos\" & txttemp.Text & "'," & cmbbuiltin.Text & ")"
This is supposed to insert a record into the database, but it doesn't and nor does it produce any error at runtime However using Debug.print i get the following output :
INSERT INTO Plot (Title, Agent_id, Location, Price, Type, Bedrooms, Bathrooms, FloorArea, Description, photo, builton) values('sfdf',2,'sdf',343234,'Apartment',01,01,234324,'sdfsdfds','C:\22 Acres\photos\3.jpg',1980)
Which works perfectly fine while running the query in Visual Data Manager
What's going wrong ?
-
Apr 15th, 2007, 06:08 AM
#2
Frenzied Member
Re: Not inserting into DB
What is plotadder? If you're setting a .recordsorce of a control, you wouldn't use an INSERT statement, and it wouldn't perform an INSERT anyway. You need to execute the statement, not set it as a recordsource.
Tengo mas preguntas que contestas
-
Apr 15th, 2007, 06:13 AM
#3
Thread Starter
New Member
Re: Not inserting into DB
Plotadder is the standard data control. How do i execute SQL in VB 6 ? Sorry a total n00b here
-
Apr 15th, 2007, 07:13 AM
#4
Frenzied Member
Re: Not inserting into DB
Well, I don't use a datacontrol. And due to work, don't use ADO much, which is what you want here.
I could give you the DAO code to do this, but you really should use ADO from VB6. There are plenty of examples on the forums here, but basically you want to declare & set a connection object, then use that to execute your SQL string. Look in the FAQ's for Beacon's ADO tutorial.
If si, Hack or one of the other gurus who know this better don't chime in, I'll look it up and post something myself.
Tengo mas preguntas que contestas
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
|