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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO insert

Status
Not open for further replies.

octane

Programmer
Aug 19, 2001
12
MX
I'm using VB6 and SQL Server 7
Here is the code

Dim rcd As New ADODB.Recordset

Private Sub cmdGuardar_Click()
Dim sSQL As String
sSQL = "select * from alta_prod where id_prod = 0"

rcd.Open sSQL, cn, adOpenKeyset, adLockOptimistic
rcd.AddNew
rcd.Fields("ID_PROD") = cmbProductos.ItemData(cmbProductos.ListIndex)
rcd.Fields("FEC_ALTA") = Date
rcd.Fields("CANT_PROD_ALTA") = txtCantidad
rcd.Fields("REALIZO_ALTA") = txtRealizo

rcd.Update 'at this point the VB hangs up
rcd.Close
End Sub

The program inserts data into the table but after that the program Locks and not responding, There aren't any VB error o SQL error, the app just hangs up
 
Why do you want to restrict the recordset to one record (i.e. where id_prod=0) and then try to add new records to it?
Try putting your sql as just "alta_prod", or "Select * from alta_prod" and it may sort your problem.

Also put a timeout for your connection for 15 seconds and the app should only hang for 15 seconds if things dont work.
 
Since nothing seems to be happening that would require a recordset, why use one at all? Just set up your connection object and use conObject.execute strSQL, where strsql is an "Insert..." sql statement. It will do a quick deposit of the new line, and a lot faster than the recordset/addnew approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top