我有这段代码:
@"SELECT * +
@"INTO [Excel 12.0 Xml;HDR=YES;DATABASE=C:\__tmp\zzzNew.xlsx].[Sheet1] " +
@"FROM SampleData";
导出时可以在哪里添加类别? 即:WHERE Date > "& txtDate.text &
答案 0 :(得分:0)
只需将WHERE子句添加到SQL语句的末尾,就像这样(在C#中,但VB.NET代码非常相似):
using (var cmd = new OleDbCommand())
{
string txtDate_text = "2013-02-01";
cmd.Connection = con;
cmd.CommandText =
@"SELECT * " +
@"INTO [Excel 12.0 Xml;HDR=YES;DATABASE=C:\__tmp\zzzNew.xlsx].[Sheet1] " +
@"FROM SampleData " +
@"WHERE [Date]=?";
cmd.Parameters.AddWithValue("?", txtDate_text);
cmd.ExecuteNonQuery();
}