SlideShare a Scribd company logo
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.
STEP 2: Setting Up a Database Connection
Back to Top
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.
To begin, you need to add the following three namespaces to the
top of your application code:
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.
Now you can set up the connection to your Access database that
you downloaded and put in your folder. The actual connection
string is @"Provider=Microsoft.JET.OLEDB.4.0; data
source=F:inventory.mdb". This is a standard connection string
for MS Access. You will want to precede this with the command
- string conString = so that the finished connection looks like
this.
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.
Now we need to define an OleDbConnection that will be used to
connect to the database. To do this you will need to define a
connection variable as a new OleDbConnection and point it to
the connection string defined in the previous step. Your code
should look like the following.
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();
Last, we need to declare a variable that will be used later on.
Although this really has nothing to do with setting up the
database connection, this is as good a place as any to do this.
You need to define a single variable named rowCount as an
integer and initialize it to zero. Your code should look like the
following.
int rowCount = 0;
STEP 3: Setting Up a Data Set
Back to Top
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.
You will need to create a query string that will be used to get
the data in the "item" table. This will be a simple select
statement that will get all of the data from the table (we will be
specific regarding what is needed later). You will need to define
a string variable for this query string similar to what you did for
the connection string. When finished, your new string should
look like the following:
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.
Now you need a new OleDbDataAdapter to work with the
dataset. To do this you will need to define an object named
DataAdapter as a new OleDbDataAdapter and then use the
selectStr created above and the connection variable create to
load it. Your code should look like the following:
OleDbDataAdapter DataAdapter = new
OleDbDataAdapter(selectStr, conn);
Now we can define the data set like the following:
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");
We now have one more step that will allow us to define which
columns we want to get data from later on. We need to define a
DataTable object based on the new dataSet. To do this you will
need the following code:
DataTable dataTable = dataSet.Tables[0];
STEP 4: Getting and Writing the Data
Back to Top
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.
STEP 5: Building the Application
Back to Top
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.
STEP 6: Testing Your Application
Back to Top
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:
Again, make sure the application, inventory.mdb, and the output
path in the application are all using the SAI430 directory on the
F: drive in Citrix.
Execute your program.
Check to make sure that the output file has the correct data in it.
Submit this file along with your code to be graded.

More Related Content

DOCX
Simple ado program by visual studio
DOCX
Simple ado program by visual studio
PDF
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
DOCX
Previous weeks work has been uploaded as well as any other pieces ne.docx
DOCX
EN1320 Module 2 Lab 2.1Capturing the Reader’s InterestSelec.docx
DOC
Cis407 a ilab 3 web application development devry university
DOC
Open microsoft visual studio/tutorialoutlet
PDF
Bt0082 visual basic2
Simple ado program by visual studio
Simple ado program by visual studio
Line Graph Analysis using R Script for Intel Edison - IoT Foundation Data - N...
Previous weeks work has been uploaded as well as any other pieces ne.docx
EN1320 Module 2 Lab 2.1Capturing the Reader’s InterestSelec.docx
Cis407 a ilab 3 web application development devry university
Open microsoft visual studio/tutorialoutlet
Bt0082 visual basic2

Similar to Once the Application has started up and you are at the Start Page, s.docx (20)

ODP
Ado Presentation
PPT
Dynamic Web Pages Ch 4 V1.0
DOCX
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
PDF
I am having trouble writing the individual files for part 1, which i.pdf
DOC
3 tier architecture in asp.net
DOC
How to design a report with fine report reporting tool
DOCX
PT1420 File Access and Visual Basic .docx
PPTX
Application of Insert and select notes.ppt x
PDF
3 Ways to Get Started with a React App in 2024.pdf
DOCX
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
PDF
Murach : How to develop a single-page MVC web
PDF
Tutorial on how to load images in crystal reports dynamically using visual ba...
DOCX
OBIEE 11g : Repository Creation Steps
DOC
Cis407 a ilab 4 web application development devry university
PPTX
Linq to sql
DOCX
unit 3.docx
PDF
Data Warehousing (Practical Questions Paper) [CBSGS - 75:25 Pattern] {2015 Ma...
PDF
Visual Basic.Net & Ado.Net
PDF
Part 4 How to use EF Core with MongoDb in Blazor Server Web Application.pdf
Ado Presentation
Dynamic Web Pages Ch 4 V1.0
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
I am having trouble writing the individual files for part 1, which i.pdf
3 tier architecture in asp.net
How to design a report with fine report reporting tool
PT1420 File Access and Visual Basic .docx
Application of Insert and select notes.ppt x
3 Ways to Get Started with a React App in 2024.pdf
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
Murach : How to develop a single-page MVC web
Tutorial on how to load images in crystal reports dynamically using visual ba...
OBIEE 11g : Repository Creation Steps
Cis407 a ilab 4 web application development devry university
Linq to sql
unit 3.docx
Data Warehousing (Practical Questions Paper) [CBSGS - 75:25 Pattern] {2015 Ma...
Visual Basic.Net & Ado.Net
Part 4 How to use EF Core with MongoDb in Blazor Server Web Application.pdf

More from arnit1 (20)

DOCX
One of the recent developments facing the public administration of.docx
DOCX
One paragraph for each question 1.Discuss the work of Chuck C.docx
DOCX
One rich source of fallacies is the media television, radio, magazi.docx
DOCX
One Review of two pages is due the tenth week of class. It must be.docx
DOCX
One of the negative aspects of using nuclear power as an alternative.docx
DOCX
online 5 weeks.  There are Weekly 1- (Reading Assignments 1 – 1.docx
DOCX
Online Discussion #6 The Passing of Time2727 unread replies.2929 .docx
DOCX
One to two page summary explaining the following 1.A basi.docx
DOCX
ONEWAY alcohol BY ratingSTATISTICS DESCRIPTIVES HOMOGENEITY.docx
DOCX
One Paragrapher per question.1) The internet has significantly.docx
DOCX
Online Dating and its effects on our Interpersonal Communication..docx
DOCX
ONE QUESTIONLARGE CLASS I have given you the whole module under th.docx
DOCX
Once the training analysis is completed, the organization and employ.docx
DOCX
Once each individual selects their own feature topic, then each pers.docx
DOCX
Once an individual has become a victim of a crime, there is the myst.docx
DOCX
Once again, open and read aboutMuseo Nacional de Banco Centr.docx
DOCX
One function of a leader is to provide the vision for the organiza.docx
DOCX
One afternoon at work, Natalie received a phone call from her daught.docx
DOCX
One of the key aspects of developing a strategy for the human elemen.docx
DOCX
One of the first prison systems was called the Pennsylvania System.docx
One of the recent developments facing the public administration of.docx
One paragraph for each question 1.Discuss the work of Chuck C.docx
One rich source of fallacies is the media television, radio, magazi.docx
One Review of two pages is due the tenth week of class. It must be.docx
One of the negative aspects of using nuclear power as an alternative.docx
online 5 weeks.  There are Weekly 1- (Reading Assignments 1 – 1.docx
Online Discussion #6 The Passing of Time2727 unread replies.2929 .docx
One to two page summary explaining the following 1.A basi.docx
ONEWAY alcohol BY ratingSTATISTICS DESCRIPTIVES HOMOGENEITY.docx
One Paragrapher per question.1) The internet has significantly.docx
Online Dating and its effects on our Interpersonal Communication..docx
ONE QUESTIONLARGE CLASS I have given you the whole module under th.docx
Once the training analysis is completed, the organization and employ.docx
Once each individual selects their own feature topic, then each pers.docx
Once an individual has become a victim of a crime, there is the myst.docx
Once again, open and read aboutMuseo Nacional de Banco Centr.docx
One function of a leader is to provide the vision for the organiza.docx
One afternoon at work, Natalie received a phone call from her daught.docx
One of the key aspects of developing a strategy for the human elemen.docx
One of the first prison systems was called the Pennsylvania System.docx

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Basic Mud Logging Guide for educational purpose
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Classroom Observation Tools for Teachers
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
01-Introduction-to-Information-Management.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial disease of the cardiovascular and lymphatic systems
Basic Mud Logging Guide for educational purpose
TR - Agricultural Crops Production NC III.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
VCE English Exam - Section C Student Revision Booklet
Abdominal Access Techniques with Prof. Dr. R K Mishra
Classroom Observation Tools for Teachers
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Complications of Minimal Access Surgery at WLH
Supply Chain Operations Speaking Notes -ICLT Program
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
01-Introduction-to-Information-Management.pdf

Once the Application has started up and you are at the Start Page, s.docx

  • 1. 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. STEP 2: Setting Up a Database Connection Back to Top 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.
  • 2. To begin, you need to add the following three namespaces to the top of your application code: 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. Now you can set up the connection to your Access database that you downloaded and put in your folder. The actual connection string is @"Provider=Microsoft.JET.OLEDB.4.0; data source=F:inventory.mdb". This is a standard connection string for MS Access. You will want to precede this with the command - string conString = so that the finished connection looks like this. 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. Now we need to define an OleDbConnection that will be used to connect to the database. To do this you will need to define a connection variable as a new OleDbConnection and point it to the connection string defined in the previous step. Your code should look like the following. OleDbConnection conn = new OleDbConnection(conString);
  • 3. Now you can connect and open the database with the following command entered right below the line above. conn.Open(); Last, we need to declare a variable that will be used later on. Although this really has nothing to do with setting up the database connection, this is as good a place as any to do this. You need to define a single variable named rowCount as an integer and initialize it to zero. Your code should look like the following. int rowCount = 0; STEP 3: Setting Up a Data Set Back to Top 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. You will need to create a query string that will be used to get the data in the "item" table. This will be a simple select statement that will get all of the data from the table (we will be specific regarding what is needed later). You will need to define a string variable for this query string similar to what you did for the connection string. When finished, your new string should look like the following: string selectStr = "SELECT * FROM item";
  • 4. 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. Now you need a new OleDbDataAdapter to work with the dataset. To do this you will need to define an object named DataAdapter as a new OleDbDataAdapter and then use the selectStr created above and the connection variable create to load it. Your code should look like the following: OleDbDataAdapter DataAdapter = new OleDbDataAdapter(selectStr, conn); Now we can define the data set like the following: 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"); We now have one more step that will allow us to define which columns we want to get data from later on. We need to define a DataTable object based on the new dataSet. To do this you will need the following code: DataTable dataTable = dataSet.Tables[0]; STEP 4: Getting and Writing the Data Back to Top So far we have put everything together to get the data from the database into our program. Now we need to deal with writing
  • 5. 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. STEP 5: Building the Application Back to Top You are now ready to make your last build, but first you need to make two changes to the properties for your project.
  • 6. 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. STEP 6: Testing Your Application
  • 7. Back to Top 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: Again, make sure the application, inventory.mdb, and the output path in the application are all using the SAI430 directory on the F: drive in Citrix. Execute your program. Check to make sure that the output file has the correct data in it. Submit this file along with your code to be graded.