473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Update Record Set - Error

8
Hi,

I've put the following code into my VB project for Adding a new record and when I run the programe The following is highlighted and the record set is not updated.
Set rs1 = cn1.Execute(sqlstring)

rivate Sub Command1_Click()
'Add New Record ######################
Dim sqlstring As String
'If (text1ClientId <> "") And (text3Initials <> "") And (text4FirstName <> "") And (text5Surname <> "") _
'And (text6Address1 <> "") And (text12DOB <> "") Then

If (Text1.Text <> "") And (Text5.Text <> "") Then
sqlstring = "INSERT INTO ClientTable (ClientId,Title,Initials,FirstName,Surname,DOB,Tel ephone,Address1," & _
"Address2,Town,County,PostCode,Salutation)" _
& "VALUES ('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text _
& "','" & Text5.Text & "','" & CDate(Text6.Text) & "','" & Text7.Text & "','" & Text8.Text _
& "','" & Text9.Text & "','" & Text10.Text & "','" & Text11.Text & "','" & Text12.Text _
& "','" & Text13.Text & "')"

Set rs1 = cn1.Execute(sqlstring)


'Show recorded added #################
MsgBox "New record Added"

Else
MsgBox "You must enter ClientID, ClientInitials, ClientFirstName,ClientSurname, " & _
"ClientAddress1 and ClientDOB."
End If

End Sub



Private Sub Form_Load()
Text1.Text = "C0023"
Text2.Text = "R"
Text3.Text = "EE"
Text4.Text = "JJJ"
Text5.Text = "GGGGGGGGGGGGG"
Text6.Text = "10/08/1990"
Text7.Text = "AAAAAAAAAAA"
Text8.Text = "BBBBBBBBBBBBBB"
Text9.Text = "CCCCCCCCCCCCCCCC"
Text10.Text = "DDDDDDDDDDDDDD"
Text11.Text = "EEEEEEE"
Text12.Text = "Ne25 8PY"
Text13.Text = "Hand Shake"
' Text1.SetFocus
End Sub
May 19 '07 #1
1 1145
cmrhema
375 256MB
Hi,

I've put the following code into my VB project for Adding a new record and when I run the programe The following is highlighted and the record set is not updated.
Set rs1 = cn1.Execute(sqlstring)

rivate Sub Command1_Click()
'Add New Record ######################
Dim sqlstring As String
'If (text1ClientId <> "") And (text3Initials <> "") And (text4FirstName <> "") And (text5Surname <> "") _
'And (text6Address1 <> "") And (text12DOB <> "") Then

If (Text1.Text <> "") And (Text5.Text <> "") Then
sqlstring = "INSERT INTO ClientTable (ClientId,Title,Initials,FirstName,Surname,DOB,Tel ephone,Address1," & _
"Address2,Town,County,PostCode,Salutation)" _
& "VALUES ('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text _
& "','" & Text5.Text & "','" & CDate(Text6.Text) & "','" & Text7.Text & "','" & Text8.Text _
& "','" & Text9.Text & "','" & Text10.Text & "','" & Text11.Text & "','" & Text12.Text _
& "','" & Text13.Text & "')"

Set rs1 = cn1.Execute(sqlstring)


'Show recorded added #################
MsgBox "New record Added"

Else
MsgBox "You must enter ClientID, ClientInitials, ClientFirstName,ClientSurname, " & _
"ClientAddress1 and ClientDOB."
End If

End Sub


Perhaps you have misquoted one of the details. I would rather suggest that you update the below way which is much clearer
Sample code

Expand|Select|Wrap|Line Numbers
  1. If Rs1.State = adStateOpen Then Rs1.Close
  2.         Rs1.Open "select * from ClientTable",cn1, adOpenDynamic, adLockOptimistic
  3.         Rs1.AddNew
  4.         Rs1("code") = Trim(txtCODE.Text)
  5.     Rs1("name") = Trim(txtNAME.Text)
  6.     Rs1("billno") = Trim(txtBILLNO.Text)
  7. ' Here I would suggest one more thing. Try using dtpicker control for dates. Here there is no need to convert to date
  8.         Rs1.Update
  9.         MsgBox "Added new details"
  10.         Rs1.Close
  11.  
Try out and reply
Good luck
May 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
4
by: dhcomcast | last post by:
We're starting to use Oracle for the back-end instead of a separate Access .mdb file for the data and everything as gone surprisingly well so far. We are learning Oracle as we go; Yikes! But we...
5
by: Hennie | last post by:
When trying to update a record in an editable datagrid I ran into a few problems. My update procedure is just not working. Can someone please have a look at my code and see what am I doing wrong....
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
3
by: Jeff Brown | last post by:
Does anyone else ever feel like just giving up!!!!! When i edit a record and then update the database i get an error, although i can add a new record completely. The error is : An unhandled...
3
by: PAUL | last post by:
Hello, I have 2 datasets I am trying to update. The parent table seems to update fine but when I go update the chiled table I get an error message that says I need a related record in the parent...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
1
by: komatouch09 | last post by:
Hi I am new to visual basic. I write program to navigate & update data from table. My database is in Informix & use ODBC connection. When I nevigate the data it works properly. When I Update the...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.