C#从数据库提取并显示时间的格式问题
如图,查询出来显示的格式和数据库中的格式不一样额。。。怎么弄?查询代码如下:privatevoidbutton2_Click(objectsender,EventArgs...
如图,查询出来显示的格式和数据库中的格式不一样额。。。怎么弄?
查询代码如下:
private void button2_Click(object sender, EventArgs e)
{
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=Location.mdb";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
con.Open();
int i = Convert.ToInt16(textBox1.Text);
OleDbCommand cmd = new OleDbCommand("Select * From data where ID>=@id", con);
cmd.Parameters.AddWithValue("@id", i);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
textBox1.Text = reader[0].ToString();
textBox2.Text = reader[1].ToString();
textBox3.Text = reader[2].ToString();
textBox4.Text = reader[3].ToString();
textBox5.Text = reader[4].ToString();
textBox6.Text = reader[5].ToString();//显示时间。。。
textBox7.Text = reader[6].ToString();
reader.Close();
con.Close();
} 展开
查询代码如下:
private void button2_Click(object sender, EventArgs e)
{
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=Location.mdb";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
con.Open();
int i = Convert.ToInt16(textBox1.Text);
OleDbCommand cmd = new OleDbCommand("Select * From data where ID>=@id", con);
cmd.Parameters.AddWithValue("@id", i);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
textBox1.Text = reader[0].ToString();
textBox2.Text = reader[1].ToString();
textBox3.Text = reader[2].ToString();
textBox4.Text = reader[3].ToString();
textBox5.Text = reader[4].ToString();
textBox6.Text = reader[5].ToString();//显示时间。。。
textBox7.Text = reader[6].ToString();
reader.Close();
con.Close();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询