Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '1'. Source Error:
Line 29: mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString
Line 30: Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas=" + Label1.Text, mySQLConnection)
Line 31: da.Fill(dt) Line 32: ds.Tables(0).Merge(dt)
Line 33: rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt"))
Code :
Label1.Text = Session("Kelas")
Dim rptDoc As New ReportDocument
Dim ds As New DataSet1
Dim mySQLConnection = New SqlConnection()
Dim dt As New DataTable
dt.TableName = "Student Report"
mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString
Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas=" + Label1.Text, mySQLConnection)
da.Fill(dt)
ds.Tables(0).Merge(dt)
rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt"))
rptDoc.SetDataSource(ds)
CrystalReportViewer1.ReportSource = rptDoc
i want to display selected student information so how it can be done..?
i'm not expert in query so i think my query got problem,
i need help for this problem, hope expertise here can help me
According to your situation, I don't think it's something related to Crystal Report itself but to your SQL statement——So I hope that you can debug your SQL statement and then paste it into your SQL management Studio to test whether it works properly or not.
My Suggestion:
Label1.Text = Session("Kelas").ToString() Dim rptDoc As New ReportDocument
Dim ds As New DataSet1
Dim mySQLConnection = New SqlConnection()
Dim dt As New DataTable
dt.TableName = "Student Report"
mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString
Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas='" + Label1.Text+"'", mySQLConnection) da.Fill(dt)
ds.Tables(0).Merge(dt)
rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt"))
rptDoc.SetDataSource(ds)
CrystalReportViewer1.ReportSource = rptDoc
Marked as answer by afastars on Nov 26, 2012 07:17 AM
afastars
Member
52 Points
221 Posts
Display Selected User Information On Crystal Report
Nov 25, 2012 08:32 AM|LINK
hi all expertise,
Currently i'm develop crystal report..i follow step by step from this web site http://www.codeproject.com/Articles/142064/Step-by-Step-Creation-of-Crystal-Report-using-its, but i got error , below is my Error and Code:
Error:
Incorrect syntax near '1'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '1'.
Source Error:
Line 29: mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString Line 30: Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas=" + Label1.Text, mySQLConnection) Line 31: da.Fill(dt) Line 32: ds.Tables(0).Merge(dt) Line 33: rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt"))Code :
Label1.Text = Session("Kelas") Dim rptDoc As New ReportDocument Dim ds As New DataSet1 Dim mySQLConnection = New SqlConnection() Dim dt As New DataTable dt.TableName = "Student Report" mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas=" + Label1.Text, mySQLConnection) da.Fill(dt) ds.Tables(0).Merge(dt) rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt")) rptDoc.SetDataSource(ds) CrystalReportViewer1.ReportSource = rptDoci want to display selected student information so how it can be done..?
i'm not expert in query so i think my query got problem,
i need help for this problem, hope expertise here can help me
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Display Selected User Information On Crystal Report
Nov 26, 2012 12:41 AM|LINK
Hello,
According to your situation, I don't think it's something related to Crystal Report itself but to your SQL statement——So I hope that you can debug your SQL statement and then paste it into your SQL management Studio to test whether it works properly or not.
My Suggestion:
Label1.Text = Session("Kelas").ToString() Dim rptDoc As New ReportDocument Dim ds As New DataSet1 Dim mySQLConnection = New SqlConnection() Dim dt As New DataTable dt.TableName = "Student Report" mySQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("default").ConnectionString Dim da As New SqlDataAdapter("select Nama,NoIc from MaklumatPelajar where Kelas='" + Label1.Text+"'", mySQLConnection) da.Fill(dt) ds.Tables(0).Merge(dt) rptDoc.Load(Server.MapPath("MaklumatPelajar.rpt")) rptDoc.SetDataSource(ds) CrystalReportViewer1.ReportSource = rptDocafastars
Member
52 Points
221 Posts
Re: Display Selected User Information On Crystal Report
Nov 26, 2012 06:37 AM|LINK
hi decker,
thanks for reply, can you explain what is that mean for Session("Kelas").ToString()..?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Display Selected User Information On Crystal Report
Nov 26, 2012 06:40 AM|LINK
just to convert the value in Session to a string type to be assigned to Text.
afastars
Member
52 Points
221 Posts
Re: Display Selected User Information On Crystal Report
Nov 26, 2012 07:16 AM|LINK
hai decker,
you resolve my problem...thanks a lot's