desmondtan Posted January 6, 2003 Posted January 6, 2003 When I run Sqladapter1.fill(Dataset) , one of the textbox filled with date and time . How to I format the textbox so that It only displayed Short date (without time) ? TQ Quote
*Experts* Nerseus Posted January 6, 2003 *Experts* Posted January 6, 2003 Are you binding the TextBox or manually putting in the value? If you're doing it manually, you can use the .ToString method of the column in your DataSet. If you're binding, you'll have to hook into the DataSet's bind and parse events. Check the help files for info on these two events and how to hook them up so they convert data to/from one type to another. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
desmondtan Posted January 6, 2003 Author Posted January 6, 2003 Hi Nerseus I populate the form manually by using dats reader . My code: If mydataReader.Read() Then txtDOB.text = myDataReader.Item ("DOB").To string() txt..... End if I tried to write as : txtDOB.text = myDataReader.Item ("DOB").To string("d") but errors on code. Thank you . Quote
*Experts* Nerseus Posted January 6, 2003 *Experts* Posted January 6, 2003 Is the DOB column a DateTime and non-null (System.DBNull.Value)? -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
desmondtan Posted January 6, 2003 Author Posted January 6, 2003 The DOB column is datetime and allow null . Quote
*Experts* Nerseus Posted January 6, 2003 *Experts* Posted January 6, 2003 Does the current value contain a null? This might fail on a ToString (can't remember offhand). If it's not null, try casting it as DateTime and then do a ToString, as in: txtDOB.text = ((DateTime)myDataReader.Item ("DOB")).To string("d"); -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.