473,387 Members | 1,859 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,387 software developers and data experts.

Access DS TextBox - wrong value


How do I format a DataSet (DS), generated from Access, which loads a Textbox
(TB) to only show the date in the TB instead of the date and the time?

Details:
My TB is filled by a DS containing the Date column from an Access file (i.e.
DS - TableName.DateIn). Access file only shows date (no time). Originally,
this date column was a string so I
1. Changed the column DataType in Access to a Date/Time
2. Changed Visual Studio DS schema and selected Date for field

I've tried things like mm/dd/yyyy and "short date" in Access format field
for column.

Nov 16 '05 #1
4 1355
Steve,

You can format the date by Converting the row in the data set to a date time
and then use the invariant DateTimeFormatInfo to format the string. I have
pasted some sample code below.

I hope this helps!

----------------------

DateTime dt = Convert.ToDateTime(ds.Tables[0].Rows[0][0]);
textBox1.Text = dt.ToString("mm/dd/yyyy");

Nov 16 '05 #2
I don't think that's what the OP wants, rather, he would like to be able
to specify in the binding how to do this.

In .NET 1.1, you should just hook up to the Format event on the Binding
instance for your property that is bound to the date. You will be able to
specify the format or perform it yourself here, and have the date come out
correctly.

In .NET 2.0, it gets easier, by setting the FormatString property on the
Binding instance that manages the binding between the data source and the
control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
Steve,

You can format the date by Converting the row in the data set to a date
time
and then use the invariant DateTimeFormatInfo to format the string. I
have
pasted some sample code below.

I hope this helps!

----------------------

DateTime dt = Convert.ToDateTime(ds.Tables[0].Rows[0][0]);
textBox1.Text = dt.ToString("mm/dd/yyyy");

Nov 16 '05 #3
Nicholas,

Now that I look at the question again I think you may be correct. I believe
what caught my eye was the formatting string at the end of the author's
message. At the very least multiple ways are covered and (hopefully) the
original author will now have his pick! ;-)

Cheers
Nov 16 '05 #4
Thank You, Thank You

I think Brian answered my question but I think I can implement it the way
Nickolas is suggesting during a Format event (collectionchanged_event ??,
textChanged?) if I understand your answers

I wanted to state something like this in the VS property window:
dataset - TableName.DateIn(mm/dd/yy)

My concern is I have Update() dB with correct datatype fro the TB. I didn't
know if the time was coming from the DS or Access (e.g. my last statement in
post). Although, I thought I fixed it because I indicated "date" in the DS
schema and not "datetime"

Steve
"Brian Brown" wrote:
Nicholas,

Now that I look at the question again I think you may be correct. I believe
what caught my eye was the formatting string at the end of the author's
message. At the very least multiple ways are covered and (hopefully) the
original author will now have his pick! ;-)

Cheers

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
5
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I...
6
by: gsb58 | last post by:
Hi! Recently we, in Norway changed to three different VAT levels. All three needs to be on the invoice program. This is easy obtained via a new field and set the rowsource to valuelist and make...
5
by: sklett | last post by:
I'm not real experienced with asp.net so this may be obvious. I've got a situation where some of my client side javascript is causing my posted form's controls to lose their values. In other...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
4
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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,...
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.