473,569 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql Problem ( Adding Records)

72 New Member
HI vb Wizards, good day, just wanted to ask if somebody there can help me iwth my problem. Am having difficulty in adding up records in my table, the table is in Microsoft Access format.

It Like this when i run my program, there no conflicts at no error pop up message or anything. but not satisfied with the outcome, here my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command3_Click()
  2. Dim rsShowRec As New ADODB.Recordset
  3. Dim cnn As New ADODB.Connection
  4.  
  5. Set cnn = New ADODB.Connection
  6. cnn.ConnectionString = _
  7.  "Provider=Microsoft.Jet.OLEDB.3.51;" & _
  8.           "Data Source=" & App.Path & "\dbTimeScheduling2.mdb;"
  9. cnn.Open
  10.  
  11.  
  12.  
  13. Set rsShowRec = New ADODB.Recordset
  14.  
  15. For x = 0 To 15
  16. rsShowRec.Source = "Select * from RECORDS Where CODE = 'txtCode(x).Text' "
  17. rsShowRec.Open , cnn, adOpenStatic, adLockOptimistic
  18.  
  19.     If Not rsShowRec.EOF Then
  20.         Else
  21.             rsShowRec.AddNew
  22.                 If IsNull(txtCode(x).Text) Then rsShowRec.Fields("CODE") = "" Else rsShowRec.Fields("CODE") = UCase(txtCode(x).Text)
  23.  
  24.             rsShowRec.Update
  25.             Set rsShowRec = Nothing
  26.     End If
  27. Next
  28.  
  29.     MsgBox ("Records are Added")
  30. End Sub
  31.  
it doesnt anything at all, it appends a blank entries on my tables, but thats not what i want... i do suspect that theres a problem on my sql statement, i hope somebody can configure out or tell me whats wrong with my codes.

Really hoping fro your help... i cant understand why it doesnt add up the records in my table from my form (txtCode.txt).. but the it up add up only the rows which are blanks i dont why?.... it seems like it doesnt get value of my textboxes to save in the table..


Thank you very much for any help..
May 22 '07 #1
2 1234
brando1202
1 New Member
HI vb Wizards, good day, just wanted to ask if somebody there can help me iwth my problem. Am having difficulty in adding up records in my table, the table is in Microsoft Access format.

It Like this when i run my program, there no conflicts at no error pop up message or anything. but not satisfied with the outcome, here my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command3_Click()
  2. Dim rsShowRec As New ADODB.Recordset
  3. Dim cnn As New ADODB.Connection
  4.  
  5. Set cnn = New ADODB.Connection
  6. cnn.ConnectionString = _
  7.  "Provider=Microsoft.Jet.OLEDB.3.51;" & _
  8.           "Data Source=" & App.Path & "\dbTimeScheduling2.mdb;"
  9. cnn.Open
  10.  
  11.  
  12.  
  13. Set rsShowRec = New ADODB.Recordset
  14.  
  15. For x = 0 To 15
  16. rsShowRec.Source = "Select * from RECORDS Where CODE = 'txtCode(x).Text' "
  17. rsShowRec.Open , cnn, adOpenStatic, adLockOptimistic
  18.  
  19.     If Not rsShowRec.EOF Then
  20.         Else
  21.             rsShowRec.AddNew
  22.                 If IsNull(txtCode(x).Text) Then rsShowRec.Fields("CODE") = "" Else rsShowRec.Fields("CODE") = UCase(txtCode(x).Text)
  23.  
  24.             rsShowRec.Update
  25.             Set rsShowRec = Nothing
  26.     End If
  27. Next
  28.  
  29.     MsgBox ("Records are Added")
  30. End Sub
  31.  
it doesnt anything at all, it appends a blank entries on my tables, but thats not what i want... i do suspect that theres a problem on my sql statement, i hope somebody can configure out or tell me whats wrong with my codes.

Really hoping fro your help... i cant understand why it doesnt add up the records in my table from my form (txtCode.txt).. but the it up add up only the rows which are blanks i dont why?.... it seems like it doesnt get value of my textboxes to save in the table..


Thank you very much for any help..

Check your SQL statement.
-----

rsShowRec.Sourc e = "Select * from RECORDS Where CODE = '" & txtCode(x).Text & "' "
May 22 '07 #2
darrel
72 New Member
thank you very very very much, it works, i have a little sharing to i used jet 4.0 instead of jet 3.51, it works very well on it.. again thank you.
May 23 '07 #3

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

Similar topics

6
2402
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1 abc 2 abc 3
4
409
by: Manish Sawjiani | last post by:
Hi Experts, I am just into dot net and i want simple code for adding records into Access table (97) using oledb. There are no queries in the databases and there is only one table: Friends with the following fields: FriendID (AutoNumber) FirstName, LastName and DateOfBirth Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP ...
8
2080
by: k | last post by:
Hi all I split a database in a table-part and a all-the-rest-part and linked the tables, but my code adding records to a table crashes on Set rs = db.OpenRecordset("tblDeltakelse", dbOpenTable, dbAppendOnly) I think, some places where I do the same thing to another table it just says "Invalid Operation", I press OK and nothing happens,...
0
2085
by: brijeshmathew | last post by:
Hi I use Visual Basic 6, Service Pack 6, Microsoft ActiveX Data Objects 2.8 Library(msado15.dll) and access 2000 database using JET 4 OLE. I have an application that adds records simultaneously to the same table. During the simultaneous add and update, a Locked error occurs, and most of the times it locks all the machines. I have been...
1
1116
by: Nkagi | last post by:
Hi All, I have a problem of adding records into table, if the cursor is on the first record the record that I add replaces the first record and then I moved it to the last record and the new record replaces that last record in the table. Is there a method that I can use to make sure this doesn't happen. The thing is my program was working...
7
1996
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on subform(to frmInvoices) sfrmDetails via qryDetails. Relationship built between tblClients/tblInvoices/tblDetails by ClientID. Relationship between...
0
1144
by: Mustang97 | last post by:
I've created a custom datagrid with a custom ado connection. Everything works perfectly except now I am trying to add a button that will add records. The way I know how to do that is with the commands dim newdatarow as system.data.datarow newdatarow = <dataset.name>.<table.name>.newrow I put in.. newdatarow = db_ds.tbl_movdb.newrow
1
4747
by: Bmack500 | last post by:
I'm using the following subroutine. The two different XML files are identical with the exception of three additional records in the second one. One has 450 records, and the other has 453. After merging, I get 903 records. I guess what I expected was 3 records; just the differences in the two. The two tables have the exact same structure,...
1
1495
by: Kristilee | last post by:
I am working with an attendance database that holds records for each employee for when they are absent. For every 30 days WORKED for each employee I need to have the database automatically add a record. (it's an overly complicated attendance policy) Can this be done with a query and SQL or will I have to code in VBA? I am not super proficient...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.