Dear All:
I got a serious problem in updating the date field from vb.net to abd dbf
file. My code is as follow:
Dim ConnectionString As String
Dim cake As Date = Date.Parse(idate)
Console.WriteLine(Format(cake, "MM/dd/yyyy"))
ConnectionString = "Provider=vfpoledb;Data Source=g:\project\
cashier\data\cashier.dbc;" & _
"Mode=ReadWrite|Share Deny None;" & _
"Collating Sequence=MACHINE;" & _
"Password=''"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection
(ConnectionString)
dBaseConnection.Open()
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand("update
caslip set ref_no = " & "'" & ref.Text$ & "'" & _
" ," & "inv_amt = " & CDec(inv_amt.Text) & _
" ," & "inv_dt = " & "'" & (cake) & "'" & _
" ," & "pro_no = " & "'" & f_no & "'" & _
" ," & "dep_no = " & "'" & d_no & "'" & _
" ," & "can_ind = " & p_tick & _
" ," & "cus_code = " & "'" & ser.Text & "'"
& _
" ," & "cash_amt = " & CDec(cash.Text) & _
" ," & "c_amt = " & CDec(c_card.Text) & _
" ," & "ent_amt = " & CDec(ent.Text) & _
" ," & "c_code = " & "'" & type.Text & "'" &
_
" ," & "c_chg = " & CDec(o_chr.Text) & _
" ," & "hou_amt = " & CDec(h_use.Text) & _
" ," & "remark = " & "'" & rmk.Text & "'" &
_
" ," & "oth_amt = " & CDec(other.Text) & _
" ," & "net_amt = " & CDec(dep_amount.Text)
& _
" ," & "dis_amt = " & CDec(discount.Text) &
_
" ," & "doc_no = " & "'" & ofi_no.Text & "'"
& _
" ," & "doc_dt = " & "'" & dt.Text & "'" & _
" where inv_no = " & "'" & think & "'",
dBaseConnection)
Dim vr As System.Data.OleDb.OleDbDataReader = dBaseCommand.
ExecuteReader(CommandBehavior.CloseConnection)
dBaseConnection.Close()
vr.Close()
this coding works fine on every part except when i put in the date filed, it
gave me the error message "Data Type Mismatch". I did test every single field
from the code, and I realized that it's the date format problem. Anyone has a
solution on that?? Thanks for the help!!~ 3 8793
It's been a long time since I played with VFP, but I believe you can use the
strict date format, {^YYYY/MM/DD}
--
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk
"Ivan V via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:51***********@DotNetMonster.com... Dear All:
I got a serious problem in updating the date field from vb.net to abd dbf file. My code is as follow:
Dim ConnectionString As String
Dim cake As Date = Date.Parse(idate)
Console.WriteLine(Format(cake, "MM/dd/yyyy"))
ConnectionString = "Provider=vfpoledb;Data Source=g:\project\ cashier\data\cashier.dbc;" & _ "Mode=ReadWrite|Share Deny None;" & _ "Collating Sequence=MACHINE;" & _ "Password=''"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection (ConnectionString) dBaseConnection.Open()
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand("update caslip set ref_no = " & "'" & ref.Text$ & "'" & _ " ," & "inv_amt = " & CDec(inv_amt.Text) & _ " ," & "inv_dt = " & "'" & (cake) & "'" & _ " ," & "pro_no = " & "'" & f_no & "'" & _ " ," & "dep_no = " & "'" & d_no & "'" & _ " ," & "can_ind = " & p_tick & _ " ," & "cus_code = " & "'" & ser.Text & "'" & _ " ," & "cash_amt = " & CDec(cash.Text) & _ " ," & "c_amt = " & CDec(c_card.Text) & _ " ," & "ent_amt = " & CDec(ent.Text) & _ " ," & "c_code = " & "'" & type.Text & "'" & _ " ," & "c_chg = " & CDec(o_chr.Text) & _ " ," & "hou_amt = " & CDec(h_use.Text) & _ " ," & "remark = " & "'" & rmk.Text & "'" & _ " ," & "oth_amt = " & CDec(other.Text) & _ " ," & "net_amt = " & CDec(dep_amount.Text) & _ " ," & "dis_amt = " & CDec(discount.Text) & _ " ," & "doc_no = " & "'" & ofi_no.Text & "'" & _ " ," & "doc_dt = " & "'" & dt.Text & "'" & _ " where inv_no = " & "'" & think & "'", dBaseConnection) Dim vr As System.Data.OleDb.OleDbDataReader = dBaseCommand. ExecuteReader(CommandBehavior.CloseConnection)
dBaseConnection.Close() vr.Close()
this coding works fine on every part except when i put in the date filed, it gave me the error message "Data Type Mismatch". I did test every single field from the code, and I realized that it's the date format problem. Anyone has a solution on that?? Thanks for the help!!~
Hi Ivan and Carsten,
You're right. A FoxPro date is represented in text as {mm/dd/yyyy} (assuming
American date style) and the strict format as Carsten pointed out is
{^yyyy/mm/dd}. A SQL Command might look like:
strSQL = "Insert Into MyTable (DateField) Values ({07/12/2005})"
You can also use the FoxPro Date() function which takes the year, month, and
day in Numeric/Integer format as parameters.
strSQL = "Insert Into MyTable (DateField) Values (Date(2005, 7, 12)}
If you're actually working with dBase files and not FoxPro files YMMV.
--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP ci**************@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"CT" <ca******@spammersgoawaydotnetservices.biz> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... It's been a long time since I played with VFP, but I believe you can use the strict date format, {^YYYY/MM/DD}
-- Carsten Thomsen Enterprise Development with VS .NET, UML, AND MSF http://www.apress.com/book/bookDisplay.html?bID=105 Communities - http://community.integratedsolutions.dk
"Ivan V via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message news:51***********@DotNetMonster.com... Dear All:
I got a serious problem in updating the date field from vb.net to abd dbf file. My code is as follow:
Dim ConnectionString As String
Dim cake As Date = Date.Parse(idate)
Console.WriteLine(Format(cake, "MM/dd/yyyy"))
ConnectionString = "Provider=vfpoledb;Data Source=g:\project\ cashier\data\cashier.dbc;" & _ "Mode=ReadWrite|Share Deny None;" & _ "Collating Sequence=MACHINE;" & _ "Password=''"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection (ConnectionString) dBaseConnection.Open()
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand("update caslip set ref_no = " & "'" & ref.Text$ & "'" & _ " ," & "inv_amt = " & CDec(inv_amt.Text) & _ " ," & "inv_dt = " & "'" & (cake) & "'" & _ " ," & "pro_no = " & "'" & f_no & "'" & _ " ," & "dep_no = " & "'" & d_no & "'" & _ " ," & "can_ind = " & p_tick & _ " ," & "cus_code = " & "'" & ser.Text & "'" & _ " ," & "cash_amt = " & CDec(cash.Text) & _ " ," & "c_amt = " & CDec(c_card.Text) & _ " ," & "ent_amt = " & CDec(ent.Text) & _ " ," & "c_code = " & "'" & type.Text & "'" & _ " ," & "c_chg = " & CDec(o_chr.Text) & _ " ," & "hou_amt = " & CDec(h_use.Text) & _ " ," & "remark = " & "'" & rmk.Text & "'" & _ " ," & "oth_amt = " & CDec(other.Text) & _ " ," & "net_amt = " & CDec(dep_amount.Text) & _ " ," & "dis_amt = " & CDec(discount.Text) & _ " ," & "doc_no = " & "'" & ofi_no.Text & "'" & _ " ," & "doc_dt = " & "'" & dt.Text & "'" & _ " where inv_no = " & "'" & think & "'", dBaseConnection) Dim vr As System.Data.OleDb.OleDbDataReader = dBaseCommand. ExecuteReader(CommandBehavior.CloseConnection)
dBaseConnection.Close() vr.Close()
this coding works fine on every part except when i put in the date filed, it gave me the error message "Data Type Mismatch". I did test every single field from the code, and I realized that it's the date format problem. Anyone has a solution on that?? Thanks for the help!!~
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bborden |
last post by:
When I save a document in Word that I have transferred from VBA to
Word I notice that the "Save As" file name is for, instance, "December
4.doc". Since the date is the first field I print on the...
|
by: Glenn M |
last post by:
I have a shared XML file on a server .
i also have one xslt file that performs a simple transform on in to
view the data.
now i want to have another page that lets users modify the shared xml...
|
by: ferd |
last post by:
Hello,
I want to query an access database in ASP (classic) and save the
results as an XML file that I can use as a Data Island in Internet
Explorer - I have the recordset, I can save it as XML,...
|
by: david.lindsay.green |
last post by:
Hello all, I am quite new a web scripting and making web pages in
general and I have stumbled across a problem I have as yet been unable
to solve. I am trying to take the contents of a textarea box...
|
by: Jonny |
last post by:
Hello Group
How do I open a Save File Dialog from an ASPX page behind a browse button?
Any help would be fantastic!!
I am using ASP.NET 1.1 using VB.NET as the coding language
TIA
|
by: mbyrd1332 |
last post by:
Just wondering if any of you knew of a way to trap the <!-- #BeginDate
format:Am1 -->April 4, 2006<!-- #EndDate --> (Dreamweaver's
Auto-Update-on-Save Date Code) into a PHP variable and still have...
|
by: amrhi |
last post by:
Hy Guys , Can anybody help me ?
I try to make small web database in my unit.
Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to...
|
by: Shannon Richards |
last post by:
Hello All: I have implemented a custom configuration section in my
app.config file as follows:
<configSections>
<section name="AdminUIConfig"
type="TestMgr.UIConfigSection,TestMgr"/>...
|
by: Boxcar74 |
last post by:
Hi Everybody!!!
I have an Issue.
I have an Excel file that queries an Access db. I’m trying to have it so I don’t have to keep updating it manually everyday and save it to a network drive...
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I have a question for you.
I have a .csv file which has many lines of data.
Each line has many data fields which are delimited by ",".
Now I need to extract part of data from this...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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: 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...
| |