|
|
|
Error แบบนี้ต้องแก้จยังไงครับ OleDbDataAdapter BETWEEN |
|
|
|
|
|
|
|
Code (C#)
static public DataTable GetTable(DateTime dstart,DateTime dfinal , string _File)
{
string _ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _File;
System.Data.OleDb.OleDbConnection conn =
new System.Data.OleDb.OleDbConnection(Properties.Settings.Default.Acc_mainConnectionString);
conn.Open();
string strQuery = "SELECT INV_TaxDoc.BranchID, INV_TaxDoc.DocNO, INV_TaxDoc.[Date]," +
"INV_TaxDoc.TaxNo, IC_Product.Name, INV_TaxDocSub.PricePerUnit, " +
" INV_TaxDocSub.TotalPrice, IC_PdtGroup.Name AS _Section FROM " +
"((IC_Product INNER JOIN (INV_TaxDocSub INNER JOIN INV_TaxDoc ON " +
"INV_TaxDocSub.DocNO = INV_TaxDoc.DocNO) ON IC_Product.Code = INV_TaxDocSub.PdtCode) " +
" INNER JOIN IC_PdtGroup ON INV_TaxDocSub.PdtGroupCode = IC_PdtGroup.Code) " +
"WHERE INV_TaxDoc.[Date] BETWEEN '" + dstart + "' AND '" + dfinal + "'";
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
System.Data.DataSet ds = new System.Data.DataSet();
adapter.Fill(ds);
return ds.Tables[0];
}
Tag : .NET, Ms Access, Win (Windows App), C#, Windows
|
|
|
|
|
|
Date :
2014-08-13 11:45:53 |
By :
lamaka.tor |
View :
1185 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไทไม่ส่งค่าแบบ parameter
|
|
|
|
|
Date :
2014-08-14 09:56:54 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่งค่าแบบ parameter ต้องทำยังไงครับ
อันนี้ไม่รู้จริงๆ พอดีเพิ่งหัดเขียนครับ
|
|
|
|
|
Date :
2014-08-15 15:48:46 |
By :
lamaka.tor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
using (SqlConnection connection = new SqlConnection("connection string"))
using (SqlCommand command = connection.CreateCommand())
{
DateTime start = DateTime.Now;
DateTime end = start.AddDays(10);
StringBuilder sb = new StringBuilder();
sb.AppendLine("SELECT A.[id],");
sb.AppendLine("A.[timestamp],");
sb.AppendLine("A.[Computer_Name],");
sb.AppendLine("A.[Packet_Type],");
sb.AppendLine("B.[User_Name],");
sb.AppendLine("A.[F_Q_User_Name],");
sb.AppendLine("A.[Client_Friendly_Name],");
sb.AppendLine("B.[Framed_IP_Address],");
sb.AppendLine("B.[Calling_Station_Id]");
sb.AppendLine("FROM [DBNAME].[dbo].[accounting_data] AS A");
sb.AppendLine("INNER JOIN [DBNAME].[dbo].[accounting_data] AS B ON (A.[id]=B.[id]+1)");
sb.AppendLine("WHERE A.[Packet_Type] IN (3, 4) AND A.[timestamp] BETWEEN @StartDate AND @EndDate;");
command.CommandType = CommandType.Text;
command.CommandText = sb.ToString();
command.Parameters.AddWithValue("@StartDate", startDate);
command.Parameters.AddWithValue("@EndDate", endDate);
DataTable dt = new DataTable();
using (SqlDataAdapter adapter = new SqlDataAdapter())
{
adapter.SelectCommand = command;
adapter.Fill(dt);
}
}
|
|
|
|
|
Date :
2014-08-15 16:34:42 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับ
|
|
|
|
|
Date :
2014-08-15 19:50:40 |
By :
lamaka.tor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|