| | |
Syntax Error
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Ok, I had posted this-
http://www.daniweb.com/forums/thread128689.html
and got this piece of code from a link (http://vb.net-informations.com/cryst...ery_string.htm)
The error is reported on the line-
What should have been the correct Syntax? Or does it require me to have an API to handle Crystal Reports (if it does not come native with VS 2008 Pro)
http://www.daniweb.com/forums/thread128689.html
and got this piece of code from a link (http://vb.net-informations.com/cryst...ery_string.htm)
VB.NET Syntax (Toggle Plain Text)
Imports System.Data.SqlClient Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports System.Data Public Class Form1 Dim objRpt As New CrystalReport1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cnn As SqlConnection Dim connectionString As String Dim sql As String connectionString = "data source=SERVERNAME; _ initial catalog=crystaldb;user id=sa;password=PASSWORD;" cnn = New SqlConnection(connectionString) cnn.Open() sql = procesSQL() Dim dscmd As New SqlDataAdapter(sql, cnn) Dim ds As New DataSet1 dscmd.Fill(ds, "Product") objRpt.SetDataSource(ds.Tables(1)) CrystalReportViewer1.ReportSource = objRpt CrystalReportViewer1.Refresh() End Sub Public Function procesSQL() As String Dim sql As String Dim inSql As String Dim firstPart As String Dim lastPart As String Dim selectStart As Integer Dim fromStart As Integer Dim fields As String() Dim i As Integer Dim MyText As TextObject inSql = TextBox1.Text inSql = inSql.ToUpper selectStart = inSql.IndexOf("SELECT") fromStart = inSql.IndexOf("FROM") selectStart = selectStart + 6 firstPart = inSql.Substring(selectStart, (fromStart - selectStart)) lastPart = inSql.Substring(fromStart, inSql.Length - fromStart) fields = firstPart.Split(",") firstPart = "" For i = 0 To fields.Length - 1 If i > 0 Then firstPart = firstPart & " , " _ & fields(i).ToString() & " AS COLUMN" & i + 1 MyText = CType(objRpt.ReportDefinition.ReportObjects("Text" _ & i + 1), TextObject) MyText.Text = fields(i).ToString() Else firstPart = firstPart & fields(i).ToString() & _ " AS COLUMN" & i + 1 MyText = CType(objRpt.ReportDefinition.ReportObjects("Text" & _ i + 1), TextObject) MyText.Text = fields(i).ToString() End If Next sql = "SELECT " & firstPart & " " & lastPart Return sql End Function End Class
The error is reported on the line-
Dim objRpt As New CrystalReport1 What should have been the correct Syntax? Or does it require me to have an API to handle Crystal Reports (if it does not come native with VS 2008 Pro)
•
•
Join Date: Jun 2007
Posts: 22
Reputation:
Solved Threads: 5
Sorry, I do not understand what you mean with "Importing some API"
The RT must be able to instantiate a class named "CrystalReport1", else the line
Normally you would create such a class by adding a crystal report named "CrystalReport1.rpt" into your project. For VS 2003:
The RT must be able to instantiate a class named "CrystalReport1", else the line
Dim objRpt As New CrystalReport1 cannot work.Normally you would create such a class by adding a crystal report named "CrystalReport1.rpt" into your project. For VS 2003:
- Rightclick the project in the solution explorer
- Select "Add New Item"
- Select "Crystal Report" in the "Add New Item" Dialog, give it the name "CrystalReport1.rpt", finish with "Open".
- Follow the instructions in the Crystal Report "Wizzard" Gallery.
![]() |
Similar Threads
- syntax error? .. operator overload method problemo (C)
- syntax error that I just can't seem to find! (Visual Basic 4 / 5 / 6)
- UPDATE syntax error (MySQL)
- Subshell Problem, syntax error...Help please! (Shell Scripting)
- DECLARATION SYNTAX ERROR (for bc 31 user) (C++)
- Parse error, syntax error, Forbids declaration (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Search for files within certain date range
- Next Thread: prompting when chnages have been made to a text box
Views: 1138 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse employees excel exists filter forms function html images lib listview map mobile module msaccess mysql net number open page pan panel pdf picturebox picturebox2 port position print printing printpreview problem read regex reuse richtextbox right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver storedprocedure textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vb2008 vba vbnet vista visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winsock wpf wrapingcode xml year





