473,699 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DateI n). 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 1368
Steve,

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

I hope this helps!

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

DateTime dt = Convert.ToDateT ime(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.co m

"Brian Brown" <Br********@dis cussions.micros oft.com> wrote in message
news:F8******** *************** ***********@mic rosoft.com...
Steve,

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

I hope this helps!

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

DateTime dt = Convert.ToDateT ime(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 (collectionchan ged_event ??,
textChanged?) if I understand your answers

I wanted to state something like this in the VS property window:
dataset - TableName.DateI n(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
4748
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 appreciated. Thanks in advance
9
3072
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 to appear in the report is Yes, No, or Maybe. What do I need to do to change what appears in the report/what term do I need to search out in Google? Thank you Colin
7
2227
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 tabel. I know the SP works, because a smalldatetime-field in the database is changed. I've tried to disable viewstate on all textbox controls. Any ideas to solve this problem.
2
1974
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 submit. I've read several post here and articles on the web on this topic. What little I have learned from them is that you have to pre-compile the usercontrol in order to access it in the aspx code behind. I did this, compiling the usercontrol...
5
2874
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 am useing visual studio .net, the html and code are seperated. I have the following aspx code which has two user controls: <%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %> <%@ Register TagPrefix="Subway"...
6
1679
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 the three values : 0;0,00;0,06;0,12;0,25. However my problem is calculating the orderlines and make them be summed in a textbox in the footer of the frmOrderlines.
5
2339
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 words, I have a server control TextBox, I enter some text, my client side scripts do some stuff and in the Page_Load method after submitting the form the value for my TextBox is empty. If the javascipt doesn't run, the values are fine. I've looked...
3
10800
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 months date in another textbox. and while pressing the second button (submit) i need to display the date displayed in the textbox as itself and the records between thoses two dates. if that date is still there in the textbox only i can sort the...
7
2891
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 enough memory' error whenever I scroll past N number of bytes in a textbox that has been filled with a lot of data. I am not sure what N is, but for a large chunk of data it occurs at about the halfway scroll, and smaller chunks might not throw...
4
3476
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 respective agency record appearing on the main form at the current time. Instead, what I get is the email form without the appropriate information in the textboxes of the email form.
0
8685
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6532
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
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.