Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Rows onSQL w/ VB

Status
Not open for further replies.
Oct 6, 2000
13
0
0
US
I have a series of text boxes that I want to insert their value into a new record on a MS SQL 7.0 server.
I am trying to use the INSERT command.
Code:
Me.Details.RecordSource = "INSERT into PO (PO_Number, Model) values ('" & txtinPO & "', '" & txtinmod & "'); commit;"
I get no errors but nothing is updated either.
What am I doing wrong?
 
Don't understand what you are doing but one way to do is as follows that uses ADO:

Code:
Dim cnDB as ADODB.Connection
Dim cmAddData as ADODB.Command

set cnDB as New ADODB.Connection
cnDB.ConnectionString = "your DSN or Connection String"
cnDB.Open

set cmAddData = New ADODB.Command
set cmAddData = cnDB
cmAddData.CommandType = adText
cmAddData.CommandText = "INSERT into PO (PO_Number, Model) values ('" & txtinPO & "', '" & txtinmod & "')"
cmAddData.Execute

Hope this helps, sorry if it doesn't as I didn't understand what you wanted!

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
Hi, ur sql statement is correct but u need to execute it before anything gets updated. Try it. All the best...vijay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top