新手菜鸟求助!!
用C#将TXT文档内容分类存到Access数据表格中。我这样写的:
string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=input_report.mdb";
OleDbConnection con = new OleDbConnection(conStr);
con.Open();
string cmdStr = "Insert Into ACARS (FI,[Time]) Values ('FI','Time')";
OleDbCommand cmd = new OleDbCommand(cmdStr, con);
{
cmd.ExecuteNonQuery();
}
con.Close();
MessageBox.Show("OK");
string cmdStr = "Insert Into ACARS (FI,[Time]) Values ('FI','Time')";
运行完发现Access表格里面FI,Time对应的表格里面写入的就是Values括号里面的值,我再单引号里面写啥录入的就是啥。但是我是想把TXT文档里面FI 对应的值和Time对应的值写入,这样的话Values()应该是怎么写啊?
------解决方案--------------------
你要定义啊,你先看看基础知识好不好
String FI = "a";
Stirng Time = "b";
------解决方案--------------------
string f1 = textBox1.Text;
string t=DateTime.Now.ToString();
string cmdStr = "Insert Into ACARS (FI,[Time]) Values ('"+f1+"','"+t+"')";
------解决方案--------------------
截取字符,或按空格来取,
string str = "2010-05-04 03:45:31 FI CA1534/AN B-5387";
string[] s = str.Split(' ');
string f1 = s[3] + " " + s[4];
------解决方案-------------------- string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=input_report.mdb";
string F1=" CA1534/AN B-5387"
string Time="2010-05-04 03:45:31"
OleDbConnection con = new OleDbConnection(conStr);
con.Open();
string cmdStr = "Insert Into ACARS (FI,[Time]) Values ('{0}','{1}')",F1,Time;
OleDbCommand cmd = new OleDbCommand(cmdStr, con);
{
cmd.ExecuteNonQuery();
&nb