Part-3 Crystal Reports Tutorials Using Stored Procedures with and without Parameters.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so we have successfully collected a crystal port named cr1 and now we have to display it on to our form and in order will display this report on to our form we will have to use a crystal report viewer and you can find it too easily in your toolbox in that putting section letter here you can see that the crystal report viewer one is not being shown here the reason is that our target net framework might be below then for that we have selected or it might be a client profile so we have to deal with this problem just click on the project and go to the properties and here you can see that target net framework is actually dotnet framework for client profile just click on this arrow and change the dotnet framework for client file to coordinate frame up for just click it and this message will be pop-up just click yes and it will select the target framework as dotnet framework for and this was it and if you go to toolbox again and you look in the reporting section you can see a crystal port we were just select it and drop it into your form okay and let's resize the our form so this crystal report waiver will be used and to display our crystal portrait that we have created and what we have to do is we have to type the code that will attach this crystal report one to this crystal report we were so in order to do that just double click on your form 1 and it will generate an on form load event so inside this formal load event we will type the code that will make it that will actually loads this report on to this form whenever we will load this form 1 and you can also write the code behind it buttons on click event we will see that later until for now just go to your form form 1 load event and type the following code first of all we will create an objective report document so just type the code document and they create an object of proponent and this is to document the error will be shown because we haven't included the namespace so just drag your cursor right before the world and click on this icon and on clicking it you will see using decisions dark crystal poor dot engine just click on it and it will add this namespace here ok now what we have to do is we have to actually load our report into this RDC so type RDC dot note and the brackets and here we have to type the address of our approach if you go to your solution Explorer you can see that we have a folder named reports and inside that report we have digital report one so just type here that res into double tressure marks and we will type reports the name of our folder and a little type and they just remove this bracket slash and we will put at the rate of sign here so what it will do is it will go to this reports folder and it will load this CR 1 dot our Patil vote into this report document and what we have to do is we have to and since we have a loaded our report into the PAS document now we will attach it to our crystal report viewer that's that has a name Pistol Pete Weber one so just select it and just type it crystal ball every one dot type every code source and provide the source that is the Hadees the object and just you same we will save it ok let's run this one just press control f5 or just click on start button and it will build our project and let's see if it displays dessert into a report or not you can see that it is actually displaying an error an error that says load report field the reason is that just quit it and I'll show you that just go to your solution explorer and and just go to your reports folder and select the report that you have created and right click on it go to the properties of your report and we have to change this directory to copy to output directory and we will change do not copy to copy always think now if you save it and if you rebuild your projection or just simply build it now the report will be shown without any error here you can see the reports this is this was the data that we have actually stored in our data table and it is shown right on to the report I can't just close it go back to our code so this was the simplest code that they directly displays the data of the database or data table dragged till 2 on our report now whatever we have to use store procedures that since we have created is is a store procedure now we will use it to display the data on our form so we will just comment this code until we will go to the design of our form and we will we will drag and drop it button onto a form and whenever we click on this button then whenever we click on this button it will display the data from the database on to our report we were on Dover farm using the store besiegers I will just change the properties some properties of our button like texture 2 show that up and I'll change the name as well sure but junk okay no if we will click on the events button and just generate an on-click even for this button now we will type the code here but following that we have to add connection of that database into our application and just go to your server explorer click on add connection actually I already added to the connection with the I'll show you how to add a new connection just click on server name in Tercero and your server name will be shown here if it doesn't tell you know how to find the server name and just select your database name but it was simple DB click on OK and right here it will add a connection for us I believe the previously added one okay now if you go to the properties of your connection you can see that connection string right here just copied and we will first of all stole this connection string into our app dot configure file so to go to the solution Explorer double click on a broad configure file I quickly show you how to and you actually include your connection string in empro configure file just type the following code connection strings closing bracket and name would be a connection string and the provider name will be system though the data not SQL the plunge and the connection string itself it was this one and this is how we can include other precious ring in African favor file now we have to retire it from the a broken fibula file so first of all we have to add a namespace called using system at node configuration and actually it okay let me show you just to type the following code here weekly restrain the connection strength named it as connection string equals to okay system dot configuration dot configuration manager capital C throughout connection strings okay it is not the internal intelligence is not trying anything to be paws off the names face is not added properly let's go to your solution Explorer click right click on references add a reference and this reference would be located in the framework just click select framework and let it load the references so from the list of these and these references it selected so just check the system configuration and click OK and now if you type the code it will show it ok connection strings and here we have to type the name of our connection string that was the connection strength dot production strength okay now we have successful travel double connection string into this string named connect string just copy that name since we are using it we will create checks of SQL connection and eschol letter adapter and a sweet one type SQL connection connection do ask in command objection with the come on SQL editor table at that you may be wondering why it is showing error because we haven't included the name space that is using system dot Delta dot SQL client as soon as you include the name space it will actually makes it makes errors vanishes away just change the name of care and we have to actually declare all these things inside this class that is of our form let's paste it right here now you can see that it is not showing any kind of errors and we will type the following code into our buttons the on click event type using connection equals to you cascade connection and here type the name of the string that contains our connection string so that was the connection string okay no we use object of letter adapter that was the adapter equals to new the screen turtle doctor and we have to provide two parameters here the first one is the name of our store procedure that was the show all data we can go back to our SQL Server and from the programmability store procedures get all data was the name of our store procedure so just change the name get all data and if the first one is the name of the strobe usage and second one will be the connection object s collection object that was named s collection now we have to specify the type of come on we are using since we are using store procedures so we have to type the following command to make the story work type d adapter dot select come on without come on type it comes to come on type dot store procedure okay okay now we curate and we will now create the data table subject so we will type detail in D table equals two new data table and we will have to fill the data adapter using data dr. thoughtful come on and we will fill that the data of hood that adopted into our data table so type D table and it will fill the data into our data table now what we have to do is we have to type these commands that is okay first of all we will create an instance and object of your document report document the parties C tends to Unicode document and we will load our report we will roll over report into this poor documents object so type the RDC dot logo and then we have to provide that rest that is at the rate of enforce slash zero just copied from here the copy it and yes judge yes so it will load the report that was cr1 into our our DC object no we have to specify the data source for that already seen so just type already C dot said data source equals to data table G table and it will have to be the other way it has to be like this for today okay set data source as data table and the last thing would be the process of attaching our crystal report to that history report viewer so type of crystal report viewer one dot the code source and the other sources already see okay refresh the would not refresh watch actually that was report source it's already seen to just save it and now if we if I will never project and execute it it will show the error and I will tell you how to fix that I'll just let me show you the error just build your project click on start and it will project for us okay this is the errors that will be shown if you try to execute this code and the reason is that we have to okay there is a problem in our connection strings name just stop it and let's change the name actually the name contains tuple n not single n connection string and save it and execute it again so here you can see that it is now showing data on clicking the show data button no it will take some time okay you can see that the crystal tutorial is actually our application has stopped working so just cancel it close this one okay close it and now I will tell you the fix how to fix this problem just to go to your lab configure file and here in the startup tag simply type use we will type issues legacy and eg AC by legacy v2 one time activation activation policy pol bye-zee-bye and then we'll type sure okay now you have to type this this whole code into the startup Bank and just save it close it and now if we will build our project it will work this time just click on show data and it will sure shoot that up using the stored procedure ok one clicking this filter to show that now if we go back to our code let me explain it again back to you we have extra kinetic data collections object right here you can see the connections the SQL connection object we have passed the connection swing that we have retrieved from the abduction vehicle file into this connection string and after that we have created an object of data adapter and provided him to provided two parameters to it first one is the name of our stored procedure and the connection object was the second object ok second parameter now what we have to do is we have we have mentioned the command type that we have selected as the common type thought stored procedure to tell that whether we are using store procedure and we have created it at a table and then we have we have filled it filled the data table using the data dr. dot will come on and we have then created report document and we have loaded the report and the most important thing here was the we have set the data source for this RDC NEPA document object as it at a table and after that we have just simply attached the reports that we have related to this level to be over one so this is how we can actually use store seizures to display our data from the database into our crystal report
Info
Channel: Adnan Qurban
Views: 2,810
Rating: undefined out of 5
Keywords: crystal reports with and without stored procedures, stored procedure to create crystal report, crystal report with storedprocedure, load data from Stored Procedure in Crystal Report, Crystal Reports (Software), Tutorial, how to load data from stored procedure into crystal report using C#, crystal reporting tool, reporting tool, reporting, C# (Programming Language)
Id: 3bH442lyiK0
Channel Id: undefined
Length: 20min 19sec (1219 seconds)
Published: Sat Dec 17 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.