473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

vb codes for sql update

4 New Member
i'm not sure whether this shud b in vb or sql but i'm havin a problem with updating the data in access using the sql commands in vb. It seems that it will not update but no error messages were shown. So i'm simply lost in verifying the error. Here is a sample for my code:

strDate = Format(txtInvoiceDate.Text, "dd/mm/yyyy")

If saveType = 2 Then ' New Record

strSQL = "INSERT INTO tb_GTotalFL (InvoiceDate,AccNo,Discount,Tax) " _
& "VALUES ('" & txtInvoiceDate.Text & "'," _
& "'" & txtAccNo.Text & "'," _
& "" & txtDiscount.Text & "," _
& "'" & txtTax.Text & "')"
Else
'Edit Record
strSQL = "UPDATE tb_GTotalFL SET Discount=" & txtDiscount.Text & ", " _
& " Tax=" & txtTax.Text & "" _
& " WHERE AccNo='" & txtAccNo.Text & "' AND InvoiceDate= #" & strDate & "#"
End If
' Open a connection using OLEDB.
cnn.ConnectionString = VDataFile
cnn.Open
Set rs = cnn.Execute(strSQL)
'close connection
Set rs = nothing
Set cnn = nothing
cnn.close

...no errors..but wont update record edited..can any1 advice..? help is very much appreciated
Apr 22 '08 #1
3 1804
daniel aristidou
491 Contributor
i'm not sure whether this shud b in vb or sql but i'm havin a problem with updating the data in access using the sql commands in vb. It seems that it will not update but no error messages were shown. So i'm simply lost in verifying the error. Here is a sample for my code:

strDate = Format(txtInvoiceDate.Text, "dd/mm/yyyy")

If saveType = 2 Then ' New Record

strSQL = "INSERT INTO tb_GTotalFL (InvoiceDate,AccNo,Discount,Tax) " _
& "VALUES ('" & txtInvoiceDate.Text & "'," _
& "'" & txtAccNo.Text & "'," _
& "" & txtDiscount.Text & "," _
& "'" & txtTax.Text & "')"
Else
'Edit Record
strSQL = "UPDATE tb_GTotalFL SET Discount=" & txtDiscount.Text & ", " _
& " Tax=" & txtTax.Text & "" _
& " WHERE AccNo='" & txtAccNo.Text & "' AND InvoiceDate= #" & strDate & "#"
End If
' Open a connection using OLEDB.
cnn.ConnectionString = VDataFile
cnn.Open
Set rs = cnn.Execute(strSQL)
'close connection
Set rs = nothing
Set cnn = nothing
cnn.close

...no errors..but wont update record edited..can any1 advice..? help is very much appreciated
are you using vb6??
Im not to familiar with vb6 if you are using a later version use snippets
Apr 22 '08 #2
debasisdas
8,127 Recognized Expert Expert
try like this
Expand|Select|Wrap|Line Numbers
  1. cnn.BeginTrans
  2. cnn.execute "Your insert or update SQL query here."
  3. cnn.CommitTrans
Apr 22 '08 #3
alfeena
4 New Member
thx 4 the feedback..finally solved the problem..it seems that my date format is whats causing the problem. So i changed the format to (mm/dd/yyyy) n am able to update the records..thx again!
Apr 22 '08 #4

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

Similar topics

2
by: Michael | last post by:
I have to do a data migration for a client. The following conversion is required. Task: - MOVEMENT table with 7,000,000 records, each has a location code - Location code has changed; I have a...
0
by: tsolbjor | last post by:
Is there a schema available for ethical codes? Im thinking of a code of conduct document that should be easy to update and roll out to different platforms and devices. I might use some...
5
by: perryche | last post by:
Problem #1: I have a form, which says, has 2 fields: F1 & F2 (both Dates). I want to be able to change F1 and F2 will change to be the same as F1 in the codes. However, I will still be able...
2
by: Roy | last post by:
Hey all, I wish to implement a "Try..." block into my web app (which is basically an editable datagrid) to display appropriate error pages to my users. Basically, the two main error's are that the...
1
by: Remulac | last post by:
I've written a VB 6.0 program that uses Access as a back-end. Things work pretty well, but I often retrieve data into large text fields that contains formatting codes like this, for example: ...
1
by: Alex P | last post by:
Hi, i would like to check for a given query (insert, update, delete) if there is a key or constraint violation which prevents the query from being executed. Is such a feature implemented in the...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
3
by: Brian | last post by:
I know this is the wrong way to do it, but maybe someone can tell me the right way to do it... I have two different databases that I need to synchronize. The database doesn't have keys exactly,...
8
by: PW | last post by:
Hi, There is code in Alison Balter's excellant "Mastering Access 2003" to create a list of error codes and descriptions but it only generates error messages 3 through 94. Is there a website...
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
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,...
1
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...
0
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...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.