It’s been several days I looking for connecting crystal report express for visual studio 2008 using sqldatasource, so i can edit the sql query using code behind on runtime. All I found on the net are using dataset or xsd, so more coding required ![]()
But finally I found it in microsoft site, with a few simple steps:
- Create crystal report file.
- Connect to database and add fields on the report, customize it as you like.
Here I found another problem, the page wide is limited, the maximum size are E size sheet (43.5 inch) in landscape mode. so you need to limit the report page wide or using subreport.
- Create a form page.
- Add component sqldatasource, crystal report source and crystal report viewer.
- Create your query in sql data source.
- In crystal report source do these steps:
- idiedibg
- jjefdddh
- hbajfjbg
- In crystal report viewer, link the report source to crystal report source.
- finished
so now you can edit the sql query in sql data source in code behind, like for example for the select query in sqldatasource1:
Sqldatasource1.SelectCommand = “[your sql query]“


