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

Critical error when adding new record to ADO recordset

Status
Not open for further replies.

onetomany

Programmer
May 15, 2000
55
US
I have the following code in which I am trying to add a new record to a sql server table.<br>I am getting information from textboxs on a form.<br><br><br>Public acnnAdminConnection As New ADODB.Connection<br>Dim arstadminRecordset As New ADODB.Recordset<br><br><br>strConnect = &quot;Driver={SQL Server};Server=FA99STUQ05;UID=l00wmy;PWD=l00wmy;DATABASE=Project100_DEV&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;With acnnAdminConnection<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ConnectionString = strConnect<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ConnectionTimeout = 10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.CursorLocation = adUseNone<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Mode = adModeReadWrite<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Open<br>&nbsp;&nbsp;&nbsp;End With<br><br>arstadminRecordset.Open &quot;ProfileArea&quot;, acnnAdminConnection, adOpenForwardOnly, adLockOptimistic<br><br><br>Private Sub cmdAddNew_Click()<br>arstadminRecordset.AddNew<br>arstadminRecordset.Fields(&quot;Area_ID&quot;) = Text1.Text<br>arstadminRecordset.Fields(&quot;Area_VC&quot;) = Text2.Text<br>arstadminRecordset.Fields(&quot;GroupManagerAssociate_ID&quot;) = Text3.Text<br>arstadminRecordset.Fields(&quot;GroupManagerStartDate_DT&quot;) = Text4.Text<br>arstadminRecordset.Fields(4) = 1<br>arstadminRecordset.Fields(&quot;Department_ID&quot;) = Text6.Text<br>arstadminRecordset.Update<br><br>End Sub<br>Every time I attempt to click add new I get the following error message and vb quits.<br>The Instruction at '0x78001855' referenced memory at '0x00000000'. The memory could not be &quot;read&quot;.<br><br>Could anyone tell me what I am doing wrong.I am relatively new to ADO but have done similar things with DAO many times.<br>
 
First of all change your cursor location to adUseClient or adUseServer. If your ProfileArea is SQL table then add one more parameter in your recordset open line in last with adCmdTable. Try with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top