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
3 1804
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
try like this -
cnn.BeginTrans
-
cnn.execute "Your insert or update SQL query here."
-
cnn.CommitTrans
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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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:
...
| |
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...
|
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)...
|
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,...
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |