Dim Conn As New SqlClient.SqlConnection(ConnectionString)
Dim da As New Data.SqlClient.SqlDataAdapter(cmd)
Dim cmd As New System.Data.SqlClient.SqlCommand
Dim ds As New DataSet1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With cmd
.Connection = Conn
.CommandType = CommandType.StoredProcedure
.CommandText = "Get_ReportEmployee" //<-------- ชื่อ Stored Procedure
.Parameters.Add("@Id", SqlDbType.NVarChar, 6).Value = "100001"
.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = "KEN DOODEE"
End With
da.Fill =(ds,"Get_ReportEmployee") //<-------- มันจะมีหยักๆ ตรง da.Fill เหมือนกับว่า หา store procedure ไม่เจอครับ
Dim reportlocation As String = Server.MapPath("ReportEmployee.rpt")
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(Server.MapPath("ReportEmployee.rpt"))
rpt.SetDatabaseLogon("sa", "", "192.0.0.0", "Employee")
rpt.SetDataSource(ds.Tables("Get_ReportEmployee"))
Partial Class Report
Inherits System.Web.UI.Page
Dim Conn As New SqlClient.SqlConnection(ConnectionString)
Dim cmd As New System.Data.SqlClient.SqlCommand
Dim ds As New DataSet1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With cmd
.Connection = Conn
.CommandType = CommandType.StoredProcedure
.CommandText = "Get_ReportEmployee" //<-------- ชื่อ Stored Procedure
.Parameters.Add("@Id", SqlDbType.NVarChar, 6).Value = "100001"
.Parameters.Add("@Name", SqlDbType.NVarChar, 50).Value = "KEN DOODEE"
End With
Dim da As New Data.SqlClient.SqlDataAdapter(cmd)//<------ย้ายลงมานี่ได้มั้ยครับ..
da.Fill =(ds,"Get_ReportEmployee") //<-------- มันจะมีหยักๆ ตรง da.Fill เหมือนกับว่า หา store procedure ไม่เจอครับ
Dim reportlocation As String = Server.MapPath("ReportEmployee.rpt")
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(Server.MapPath("ReportEmployee.rpt"))
rpt.SetDatabaseLogon("sa", "", "192.0.0.0", "Employee")
rpt.SetDataSource(ds.Tables("Get_ReportEmployee"))
CrystalReportViewer1.ReportSource = rpt
End Sub
End Class