Once the Application has started up and you are at the Start Page, select the create a new project option. When presented with the New Project window like the one below, be sure that you have highlighted Console Application under the Templates window. Now give the new project the name INV_GRAB in the Name field, and have the location field pointing to the F:SAI430 folder you have on the F: drive. The diagram below depicts what your New Project window should look similar to.
Once you have done this, select OK to complete this operation. You may get a “Microsoft Development Environment” message box stating that the project location is not a fully trusted .NET runtime location. You can ignore this and just select OK. You should now see your new project listed in the Solution Explorer window on the upper right hand corner of the editor window. You are now ready to begin setting up your form.
The first step now is to set up a database connection with Access and then a data set that can be used to transport the data from the database to the application to be written to a file. For the purposes of this lab and your project, you will only need data from two columns in the ITEMS table of the INVENTORY database, but we will control that with the code written later. The following steps will lead you through the process of setting up the connection.
using System.IO;
using System.Data;
using System.Data.OleDb;
Since you are going to be not only connecting to a database but also writing data to a file, you will need all three of these listed.
string conString = @”Provider=Microsoft.JET.OLEDB.4.0; data source=F:SAI430inventory.mdb”;
This is simply defining a string variable named conString and assigning the connection string to it. We will use this variable later.
OleDbConnection conn = new OleDbConnection(conString);
Now you can connect and open the database with the following command entered right below the line above.
conn.Open();
int rowCount = 0;
Now you will need to set up a Data Set that will be used to hold the data that is pulled from the database so that it can be processed. This dataset will hold all of the records from the item table. We will use this data to write out our inventory list to a file.
string selectStr = “SELECT * FROM item”;
There is a variable we will need to use later on, so we might as well define and initialize at this point. The new variable is an integer data type and needs to be named rowCount. Initialize it to zero.
OleDbDataAdapter DataAdapter = new OleDbDataAdapter(selectStr, conn);
DataSet dataSet = new DataSet();
This is a simple definition that we can use along with the DataAdapter Fill method to fill the data set like the following:
DataAdapter.Fill(dataSet, “item”);
DataTable dataTable = dataSet.Tables[0];
So far we have put everything together to get the data from the database into our program. Now we need to deal with writing the data out to a file. To do this we will be using the StreamWriter class and some of its objects.
We must declare a new instance of the StreamWriter so that we can obtain its methods. At the same time we can also initialize the new writer to point to where we want the file to be written to. Your code should look like the following.
StreamWriter sw = new StreamWriter(@”F:sai430INV_GRB.txt”, false);
Now we are ready to set up the processing to loop through our data set, pull the data we need into a file, and print it out. To help with this there is a file in Doc Sharing named Lab1_code.txt. The code in this file can be copied and pasted into the area of the code section you are working, just below the line you added above. Be sure to change the directory path to match yours for the output file.
You are now ready to make your last build. If everything has been done correctly, you should end up with no error messages and clean build. Once this has been done then you are ready to execute the application by selecting Debug => Start from the main menu. If all goes well you should be able to find your output file in the location listed in the program.
You are now ready to make your last build, but first you need to make two changes to the properties for your project.
Changing the build option for 32-bit.
We need to build the application as a 32-bit application so it will work with the Microsoft ODBC drivers for Access; to do this you will need to select Project => INV_GRAB Properties from the main menu. Now select the Build tab on the side of the properties box, and then in the drop down list next to Program Target, select the X86 option. This will allow the application to build as a 32-bit application. Do not close the properties window yet though, because there is one more step.
Setting the Security option:
Now select the Security tab on the left side. Check the Enable ClickOnce Security Settings check box. This is a full trust application option, which is what you want.
Now select File => Save All from the main menu and then close the properties window.
Now you can either build or re-build the application. If everything has been done correctly, you should end up with no error messages and clean build. Once this has been done, you are ready to execute the application by selecting Debug => Start from the main menu. If all goes well you should be able to find your output file in the location listed in the program.
You first want to make sure that you have the Inventory.MDB database in the SAI430 folder on the F: of your directory structure in Citrix. This should also be the same location of your source code project and the location to which you have pointed the program to write the output file. In order to test the application and generate the output document you will need to turn in, do the following:
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more