收到的UDP数据五分钟打一个包,存入一个文件 并把文件名,文件所在的分区 收到的时间等等存入数据库
String connectionString = "server=127.0.0.1;user id=root; password=bjdj; database=mdr; pooling=false;charset=utf8;allow zero datetime=true";
MySqlConnection conn = new MySqlConnection(connectionString);
try
{
conn.Open(); string sql = "select RName,PID from recordinfo where RTime between"
+ " '" + dTPicker_StartTime1.Value.ToShortDateString() + " "
+ dTPicker_StartTime2.Value.ToLongTimeString() + "' and '"
+ dTPicker_EndTime1.Value.ToShortDateString() + " "
+ dTPicker_EndTime2.Value.ToLongTimeString() + "'";
MySqlDataAdapter dataadapter = new MySqlDataAdapter();
dataadapter.SelectCommand = new MySqlCommand(sql, conn);
DataSet dataset = new DataSet();
dataadapter.Fill(dataset);
dataGridView1.DataSource = dataset.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
现在数据库的内容都显示在datagridview中,怎么才能根据数据库存的索引 把文件提取出来 比如拷贝到指定的路径
String connectionString = "server=127.0.0.1;user id=root; password=bjdj; database=mdr; pooling=false;charset=utf8;allow zero datetime=true";
MySqlConnection conn = new MySqlConnection(connectionString);
try
{
conn.Open(); string sql = "select RName,PID from recordinfo where RTime between"
+ " '" + dTPicker_StartTime1.Value.ToShortDateString() + " "
+ dTPicker_StartTime2.Value.ToLongTimeString() + "' and '"
+ dTPicker_EndTime1.Value.ToShortDateString() + " "
+ dTPicker_EndTime2.Value.ToLongTimeString() + "'";
MySqlDataAdapter dataadapter = new MySqlDataAdapter();
dataadapter.SelectCommand = new MySqlCommand(sql, conn);
DataSet dataset = new DataSet();
dataadapter.Fill(dataset);
dataGridView1.DataSource = dataset.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
现在数据库的内容都显示在datagridview中,怎么才能根据数据库存的索引 把文件提取出来 比如拷贝到指定的路径
解决方案 »
- 随机数random
- 复杂逻辑运算(高手请进)
- C# winform显示问题
- 求教高人,为什么说值类型继承自ValueType??
- RichTextBox.Rtf导致的System.OutOfMemoryException问题
- ◥◣㊣◢◤ 小弟由VB转C#希望各位大家多多指教! ◥◣㊣◢◤
- Silverlight使用时,从工具箱拖拉控件到设计窗体时,抛出异常,System.NullReferenceException 未将对象引用设置到对象的实例。
- 有多少种启动EXCEL的方式?
- 请大家帮我看一下,我段代码为什么错,又何改正,谢谢
- 哪里有关于C#与数据库操作方面的资料,可能介绍介绍吗?
- 怎样给无边框窗口添加resize?
- 不支持直接向toolStripContainer添加控件
存放的时候其实不用存放分区,直接把文件带路径存放起来就行了有了文件路径,要把文件复制出来很简单啊File类的方法
public static void Copy (
string sourceFileName,
string destFileName,
bool overwrite
)