473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Extracting data in SQL server using crystal report

Hi All,

I am new to sql server. I am working with Sql server 2000 which has tables
containing customer details. My question is :

Is there any way to extract the data in Sql server database using Crystal Reports. I know how to use Crystal report for reporting purpose but not for extraction.Since my company will not have any sql programmer in future they are planning to do this way. Is this possible?
May 15 '07 #1
11 17652
Motoma
3,237 Expert 2GB
What do you mean, exactly, when you say "extract?"

You can use CR to query a database and build reports from that, if that is what you are asking.
May 15 '07 #2
What do you mean, exactly, when you say "extract?"

You can use CR to query a database and build reports from that, if that is what you are asking.

Yes. I have a table that contains details of Customers. For ex,

I have to pull all the details of customers whose age is greater than 20.How can i do this in CR.
May 15 '07 #3
Motoma
3,237 Expert 2GB
In the Field Explorer, Right-click on Database Fields, and select Add/Remove Database.

Yes. I have a table that contains details of Customers. For ex,

I have to pull all the details of customers whose age is greater than 20.How can i do this in CR.
May 15 '07 #4
In the Field Explorer, Right-click on Database Fields, and select Add/Remove Database.

Thanks for the reply. I have done till here. Say for example the table t1 contains
the following fileds.

Cust_id
Name
Address
City
State
Zip
Age
Date of Purchase.


Now i want a report that conatins only Name,Address and Age. I want to do this in CR. So i connected to the database and inside SQL expressions Field i wrote the following query,

SELECT name,address,age FROM t1

Is this correct. But i got a error which says

Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'


Note :I am establishing connection between CR and SQL server through ODBC driver.


So is the problem with the connection or with the query i wrote.
I have one more question. Should someone know little about SQL to query the database in CR . I am asking this question because there are no programmers here. So once i leave is it possible to do all extarctions using CR.
May 15 '07 #5
iam_clint
1,208 Expert 1GB
SELECT name, address, age FROM t1
where age > 20
May 15 '07 #6
Thanks for your reply. I wrote the query

SELECT name,address,age FROM t1 where age>20 ,but got the error

Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'

So we need to query the database in SQL through CR using SQL commands only. Is there any other way to do this?
May 17 '07 #7
Motoma
3,237 Expert 2GB
I am not sure what aspect of the original solution I posted was not acceptable for you.
May 17 '07 #8
I am not sure what aspect of the original solution I posted was not acceptable for you.

No. I accept that is the solution. But i got this error. I dont know why i am getting this error

Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'
May 17 '07 #9
Hi, I am not good at SQL server and I have never used CR but I think the problem you are facing is because of the connection between CR and SQL.

Because I used to see this message when I fail my connection between Ms. Access project and SQL server 2000. So let's rebuild your connection between this two programmes.

In fact the code you have written(select fieldname1, fieldname2..... from tablename where age>20;) was correct. So please try as I told you. I hope it may work.

Thanks
May 18 '07 #10
Motoma
3,237 Expert 2GB
Creating an SQL based report in CR does not require any manipulation inside the SQL Expression Field. Simply add your database to the Database Fields,, then drag and drop the columns onto the report.

No. I accept that is the solution. But i got this error. I dont know why i am getting this error

Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'
May 18 '07 #11
hnminh
1
Thanks for the reply. I have done till here. Say for example the table t1 contains
the following fileds.

Cust_id
Name
Address
City
State
Zip
Age
Date of Purchase.


Now i want a report that conatins only Name,Address and Age. I want to do this in CR. So i connected to the database and inside SQL expressions Field i wrote the following query,

SELECT name,address,age FROM t1

Is this correct. But i got a error which says

Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'


Note :I am establishing connection between CR and SQL server through ODBC driver.


So is the problem with the connection or with the query i wrote.
I have one more question. Should someone know little about SQL to query the database in CR . I am asking this question because there are no programmers here. So once i leave is it possible to do all extarctions using CR.
Now, I show you 2 problems:

1. To report only some fields, you choose the database, and the table you want to report (click on the Datatabase Fields item in the Field Explorer panel to open a wizard for it), then you drag and dop the columns you want onto the report. Very simple!

2. Solving your error. It is a syntax error. And here is the solution:

"Doing a SELECT in a SQL Expression field:
When teaching SQL expression fields I have always tried to stress that SQL Expressions are different from SQL Statements. A SQL Expression is a column in the report, where a SQL statement is a full query. My short version of this was to say "a SQL Expression can't do a "SELECT". Well I recently learned that this is not precisely true. Under certain situations, a SQL Expression CAN do a completely separate select from the main report.

The main limitation is that it can only return a single value. So you probably will need a summary function. The following example comes from the Xtreme Sample Database:
(SELECT Max ( Orders.`Order ID`)
FROM `Orders` Orders)

Normally a CR SQL Expression would error on the SELECT, but if you put this expression in parentheses, Crystal will pass it to the database as a separate query. Amazingly, the column being queried does not even have to come from one of the tables in the report, but can be from another table in the database. In the past I would have recommended doing this via subreport. The advantage of a SQL Expression is that the value returned can be used to control things like Selecting, Sorting and Grouping in the report. Of course, if you need to select multiple rows or multiple columns, you will need a subreport. "

(This lecture is from Ken Hamady, www.kenhamady.com)

Is it suiteable to your problem? I think so!
Jul 31 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mike | last post by:
Hello All, I'm trying to deploy my windows-based application using crystal report. i package the setup by including the crystal report file, the exe file, and two merge modules for the crystal...
0
by: Ray | last post by:
Hi all, While I use the ReportDocument of vb.net to set filter to the data to the Crystal Report, it is successful for the first time. However, for the second time, when I set filter to other set...
6
by: Ray | last post by:
Hi all, While I use the ReportDocument of vb.net to set filter to the data to the Crystal Report, it is successful for the first time while running the program. However, for the second time while...
0
by: Ray | last post by:
Dear Bernie, Yes, if the same pfieldname is used. The same data will be filtered. But I only use the code shown you before. I have not used any dataset or datatable. How to fix the problem?...
0
by: edward zhang | last post by:
I have a VB.Net application which uses the Crystal Report(Crystal Report 8.5) Viewer to open reports. One of the reports uses a stored procedure and another one uses tables as data resource, both...
0
by: Rabbit | last post by:
recently I monitor my web application using Crystal report for .net, I notice everytime I call CrystalReportView control to display the report, the memory usage go up by 2MB, upto certain level,...
2
pureenhanoi
by: pureenhanoi | last post by:
i'm using VB6 to create application. My application connect to database (MS-SQL Server) through ODBC. i'm using Crystal Report too. But there is a problem here: if my SQL Server does not need...
1
by: gzali | last post by:
hi, i want to send parameter on web by using crystal report,the problem is that i am using crystal report 8.5 i am using a heperlink on a report filed, when the user click on the heperlink the...
0
by: Jason7899 | last post by:
hi I’m creating a small program to draw up an estimate and after that I want it to be printed using the crystal report 7, and I wonder if someone has a similar sample program. I also thought of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.