lorena Posted January 13, 2006 Posted January 13, 2006 I am fumbling my way through teaching myself Crystal Reports in VS.Net 2003 I can set up a report using the Extreme.mdb provided for testing purposes. Now, I want to use code to set the database connection and report source. I thought I had it set up correctly but I am getting "ConnectionString property has not been initialized" Here is my code: Sub BindReport() Dim objConn As SqlConnection Dim uName As String = System.Configuration.ConfigurationSettings.AppSettings("mappedname") Dim pass As String = System.Configuration.ConfigurationSettings.AppSettings("mappedkey") Dim strConn As String = "SERVER=Intranet\tdsmfg;DATABASE=mtc_req;user id= " & uName & ";password= " & pass Dim objCommand As SqlCommand Dim objSqlAdapter As SqlDataAdapter objConn = New SqlConnection(Session(strConn)) objCommand = New SqlCommand objSqlAdapter = New SqlDataAdapter objCommand.Connection = objConn objCommand.CommandType = CommandType.StoredProcedure objCommand.CommandText = "Requests_Read" objConn.Open() objSqlAdapter.SelectCommand = objCommand Dim objDS As New DataSet objSqlAdapter.Fill(objDS, "requests") Dim oRpt As New rpt2 oRpt.SetDataSource(objDS) CrystalReportViewer1.ReportSource = oRpt CrystalReportViewer1.DataBind() End Sub I would appreciate any help with this. Thanks! Quote
dakota97 Posted January 20, 2006 Posted January 20, 2006 I ran into a similar problem when I was teaching myself CR.Net, and the best decision I made was to purchase Brian Bischof's book "Crystal Reports .Net Programming". You can check it out at http://www.crystalreportsbook.com . There is a "Purchase" link at the top of the site for stores that carry it. The first 1/2 of the book explains everything from start to finish on graphically creating a report. The second 1/2 explains everything about creating a report programmatically using VB.Net, and includes relative code samples for C# and ASP.Net as well. This book saved my life when I was trying to figure out how to create a receipt and various reports for my point-of-sale program. I HIGHLY recommend buying this book. In the meantime, I'll scan through my old code and see if I can't pull up a few examples on how I generated my reports and post them for you. Check out that site, and seriously consider buying the book. You won't regret it. Chris Quote if(computer.speed == "slow") { hamster.feed(); } if(computer.speed == "really slow") { hamster.kill(); BuyNewHamster(); }
lorena Posted January 22, 2006 Author Posted January 22, 2006 Thanks, Chris. Actually, I have the Bischoff book - guess I didn't get far enough into it to find out how to launch a report programmatically. Thanks for the website. I have added it to my favorites. If you do find any code, please post it. Meanwhile, I will keep digging. Thanks again! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.