Dim datereport1, datereport2 As String
datereport1 = Format(dtp_reportday.Value, "M/d") & "/" & Format(dtp_reportday.Value, "yyyy") - 543
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString As String
Dim sSql As String
strConnString = "Server=STOCK_2\SQLEXPRESS;Initial Catalog=DatadasePoDatapower;User ID=sa;Password=admin1234;"
sSql = "SELECT dbo.tb_Generation.g_name, dbo.tb_orderproduct_detail.o_color, dbo.tb_orderproduct_detail.o_length, dbo.tb_orderproduct_detail.o_typewire, dbo.tb_Generation.g_line,"
sSql += " dbo.tb_orderproduct_detail.o_amount, dbo.tb_orderproduct_detail.o_status, dbo.tb_orderproduct_detail.o_dateofcompletion"
sSql += " From dbo.tb_Generation INNER Join"
sSql += " dbo.tb_orderproduct_detail ON dbo.tb_Generation.g_name = dbo.tb_orderproduct_detail.g_name"
sSql += " WHERE o_dateofcompletion = '" & datereport1 & "' "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = sSql.ToString()
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds, "ds_day")
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
Dim rpt As New ReportDocument()
Dim Server As Object = Nothing
rpt.Load("rpt_completion_day.rpt")
rpt.SetDataSource(dt)
Me.crp_day.ReportSource = rpt