I have a method which fills-in the TextBoxes of my control.
The problem is, the date coming out has a TimeStamp, and I don't want to display it.
Is there someway I can format the value coming out of the datarow object so that it just returns a data?
public void FillPersonalInfoFromDB(string username, string connStringName)
{
string userID = CommonFunctions.GetUserIdGivenUserName(username);
string sqlStatement = "select Birthdate, SSN from aspnet_PersonalInfo where UserId = '" + userID + "'";
DataSet ds = CommonFunctions.ReturnDataSet(connStringName, sqlStatement);
foreach (DataRow dr in ds.Tables[0].Rows)
{
//4/5/1974 12:00:00 AM is what this.TextBoxBirthday.Text holds after the line below runs
// I just want to show 4/5/1974
this.TextBoxBirthday.Text = dr["Birthdate"].ToString();
this.TextBoxSSN.Text = CommonFunctions.AddDashesToSSN(dr["SSN"].ToString());
}
}
Depending on your database, you might be able to do it there too.
with sql server it would be (just as long and clunky)
select cast(convert(varchar(10), getdate(), 101) as smalldatetime) as justadate