Deccansoft Software Services - MS.NET 4.5 Database Programming using ADO.NET Agenda

Size: px
Start display at page:

Download "Deccansoft Software Services - MS.NET 4.5 Database Programming using ADO.NET Agenda"

Transcription

1 Agenda 1. Prerequisite Knowledge of SQL Queries 2. Introduction and Evolution of ADO.NET 3. Understanding the Role of Managed Provider and ADO.NET Objects 4. Installing Required Software - Sql Server and Management Studio 5. Connecting to database and Connection Pooling 6. Performing Insert, Update and Delete Operations 7. Fetching Data from database Executing Select Statements 8. How to implement Login facility with database 9. Use of Multiple Active Result Sets 10. Parameterized Prepared Statements 11. Inserting Image into Database table. 12. Executing Stored Procedure 13. Using Transaction 14. Asynchronous Execution of Queries 15. Writing Provider Independent Code 16. Writing Common Code for Execution of Stored Procedures 17. Quick Overview of all ADO.NET objects 1

2 Evolution of ADO.NET Structured Query Language = DDL + DML + DCL + DTL Data Definition Language = Create, Alter, Drop Data Manipulation Language = Insert, Delete, Update, Select Data Control Language = Grant, Revoke Data Transaction Language = Commit, Rollback, SavePoint Note: Knowledge of writing SQL Statements is expected prerequisite for this chapter. Native Drivers 1. Available in the form of Win32 Library 2. Specific to a given database 3. Different API for every new database ODBC Drivers 1. Available in the form of Win32 Libraries 2. Database independent API 3. Same API implemented differently for every database DAO / RDO Object Models 1. Object based approach for operating with Database 2. DAO Data Access Objects were used for MS.Access 3. RDO Remote Data Access Objects were used for remote databases like Oracle and SQL server. 4. Used only for datbase backends 5. Cannot be used with Excel, CSV, etc.. backends ADO (ActiveX Data Objects) 1. Common Object Model for all databases 2. Uses Ole-Db Providers instead of ODBC 3. It s a compact and efficient Object Model 4. Can be used for all types of backends including databases, excel files, csv files, s etc 2

3 ADO.NET Architecture and Role of Managed Provider ADO.NET Architecture Role of Managed Provider: It is a.net component implementing certain standard set of interfaces provided by Microsoft, for a specific type of backend. Following are the four managed providers which are built in along with MS.NET Framework. Provider Namespace API Data Source Description Name prefix ODBC System.Data.Odbc Odbc Data Sources with an ODBC interface. Normally older data bases. OleDb System.Data.Oledb OleDb Data Sources that expose an OleDb interface, i.e. Access or Excel. Oracle System.Data.OracleClient Oracle For Oracle Databases. SQL Server System.Data.SqlClient Sql For interacting with Microsoft SQL Server. More Managed Providers Oracle.ManagedDataAccess.Client is the Namespace for Managed provider provided by Oracle. MySql.Data.MySqlClient by MySql and downloaded from Important Objects in Managed Provider (ADO.NET Objects): 1. Connection: Connection object encapsulates the functionally of establishing a communication path over the sockets. 2. Command: Command Object can be used for execution of any type of Sql Statement including Stored Procedures. 3. Data Reader: Used to fetch data returned from result of execution of Select statement. 4. Data Adapter: Used to create DataSet which is disconnected model of operating with database. 3

4 Software Requirements / Installations If using Express Edition of Visual Studio: 1. Go to 2. Select and download SQL Server Express with Tools (with LocalDB, Includes the database engine and SQL Server Management Studio Express) 3. You can down load either 32 or 64-bit based on your OS (Right click on Computer Properties to find if your OS is 32-bit or 64 bit). If using VS.NET Professional or Ultimate, you will already have SQL Server Express installed on your machine. If required only SQL Server Management Studio Express can be installed and even that is not needed as most of the things can be done from VS.NET itself. Establish Connection with Database and Connection Pooling Steps to create Database and Tables In VS.NET : Creating a new Database Goto ServerExplorer Right Click on Data Connections Create New Sql Server Database Server Name as.\sqlexpress New Database name as MSNETDemoDB Creating table in Server Explorer: Emp (EmpId, EmpName, EmpSalary) table in backend. EmpId Int, PrimaryKey and also set Identity = True in Property of EmpId field EmpName Varchar(50) - AllowNull = False (Uncheck) EmpSalary Money AllowNull = True (Check) Step 1. Add to the project a file by name App.config (Application Configuration File) Edit App.config <configuration> <connectionstrings> <add name="csmsnetdb" connectionstring="server=.\sqlexpress;database=msnetdb;integrated Security=True"/> </connectionstrings> </configuration> Code: C# Step 2. Add Reference to System.Configuration (Project Reference.NET Tab Select System. Configuration OK) Step 3. Add to the project a class by name Helper (Helper.cs) Helper class: class Helper public static string ConnectionString 4

5 get return System.Configuration.ConfigurationManager.ConnectionStrings["csMSNETDB"].ConnectionString; Code: C# Step 4: To Establish Connection To test a connection Add a button on the form with name: Test Connection and ID: btntestconnection. Double click on btntestconnection and add the following code: private void btntestconnection_click(object sender, EventArgs e) SqlConnection con = new SqlConnection(); con.connectionstring = Helper.ConnectionString; try //executing commands... MessageBox.Show("Connection now open", "Status"); finally if (con.state == ConnectionState.Open) con.close(); Connection string formats for SQL Server 1. "Data Source=.\sqlexpress;Initial Catalog=MSNETDemoDb;Integrated Security=True" 2. Data Source=.\sqlexpress;Database= MSNETDemoDb; User Id=sa; Password=dss" 3. "Server=.\sqlexpress;Database= MSNETDemoDb;uid=sa;pwd=dss" Important: Data Source or Server are same Initial Catalog or Database are same User Id or uid are same Password or pwd are same We should either give Intergrated Security or uid / pwd 5

6 The ConnectionString format depends on the managed provider used for connecting to database. : to get connectionstring for all database. What is Connection Pooling? In.Net, Connections are Pooled. We can have by default up to 100 simultaneous connections without closing but obviously we have to close every connection Opened only then it can be reused from Pool i.e. keeps the connection with the database open for the short period of time. The Connection Pooling can be customized by setting appropriate parameters in ConnectionString of Connection Object and this cannot be done for Oledb and ODBC managed providers. For two or more connection objects to share a common connection in the pool their connection strings must match. <connectionstrings> <add name="msdemocs" connectionstring="server=.\sqlexpress;database=msnetdemodb;integrated Security=true; max pool size=200;pooling=false"/> </connectionstrings> Performing Insert, Update and Delete Operations Steps to execute any SQL Statement 1. Create a Connection 2. Create a Command 3. Bind the Command to Connection 4. Initialize Command with SQL Statement to execute 5. Open the Connection 6. Execute the Command 7. Close the Connection SQLCommand Methods for execution of Commands: 1. int ExecuteNonQuery(): Used for execution of those statements which do not return any data from backend to frontend. return 2. Object ExecuteScalar() - Used for execution of statements which return only one value.- return Object 3. SqlDataReader ExecuteReader() - Used for execution of statements which return multiple rows and columns i.e. a set of records. 6

7 To insert a record in the table (btninsert_click) Insert button click event: Private Sub btninsert_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btninsert.click Dim con As SqlConnection = New SqlConnection(Helper.ConnectionString) Dim cmd As SqlCommand = New SqlCommand '3. Bind the Command to Connection cmd.connection = con Dim name As String = txtname.text.replace("'", "''") Dim salary As Decimal = Decimal.Parse(txtSalary.Text) cmd.commandtext = ("Insert into Emp(EmpName, EmpSalary) Values('" _ + (name + ("'," _ + (salary + ")")))) MessageBox.Show(cmd.CommandText) cmd.commandtype = CommandType.Text '5. Open the Connection con.open() '6. Execute the Command cmd.executenonquery() MessageBox.Show ("Inserted...") '7. To Fetch the last inserted EmpId cmd.commandtext = txtid.text = cmd.executescalar.tostring '8. Close the Connection con.close() End Sub Code: VB Insert button click event: 7

8 private void btninsert_click(object sender, EventArgs e) //1. Create a Connection SqlConnection con = new SqlConnection(Helper.ConnectionString); //2. Create a Command SqlCommand cmd = new SqlCommand(); //3. Bind the Command to Connection cmd.connection = con; //4. Initialize Command with SQL Statement to execute string name = txtname.text.replace("'", "''"); decimal salary = decimal.parse(txtsalary.text); cmd.commandtext = "Insert into Emp(EmpName, EmpSalary) Values('" + name + "'," + salary + ")"; MessageBox.Show(cmd.CommandText); cmd.commandtype = CommandType.Text; //5. Open the Connection //6. Execute the Command cmd.executenonquery(); MessageBox.Show("Inserted..."); //7. To Fetch the last inserted EmpId cmd.commandtext = //** txtid.text = cmd.executescalar().tostring(); //8. Close the Connection con.close(); Code: C# Note: Over a given connection if an insert statement is executed on a table with Identity Column, the backend sql-server for that connection initializes a parameter by with the value of Identity column for the last inserted record. Update button click event: Private Sub btnupdate_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.click Dim con As SqlConnection = New SqlConnection(Helper.ConnectionString) Dim cmd As SqlCommand = New SqlCommand '3. Bind the Command to Connection cmd.connection = con Dim name As String = txtname.text.replace("'", "''") Dim salary As Decimal = Decimal.Parse(txtSalary.Text) 8

9 cmd.commandtext = ("Update Emp set EmpName='" _ + (txtname.text + ("', EmpSalary=" _ + (txtsalary.text + (" where EmpId=" + txtid.text))))) MessageBox.Show(cmd.CommandText) cmd.commandtype = CommandType.Text '5. Open the Connection con.open() '6. Execute the Command cmd.executenonquery() MessageBox.Show("Updated...") '8. Close the Connection con.close() End Sub Code: VB Update button click event private void btnupdate_click(object sender, EventArgs e) //1. Create a Connection SqlConnection con = new SqlConnection(Helper.ConnectionString); //2. Create a Command SqlCommand cmd = new SqlCommand(); //3. Bind the Command to Connection cmd.connection = con; //4. Initialize Command with SQL Statement to execute string name = txtname.text.replace("'", "''"); decimal salary = decimal.parse(txtsalary.text); cmd.commandtext = "Update Emp set EmpName='" + txtname.text + "', EmpSalary=" + txtsalary.text + " where EmpId=" + txtid.text; MessageBox.Show(cmd.CommandText); cmd.commandtype = CommandType.Text; //5. Open the Connection //6. Execute the Command cmd.executenonquery(); MessageBox.Show("Updated..."); //8. Close the Connection con.close(); Code: C# 9

10 Delete button click event Private Sub btndelete_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.click Dim con As SqlConnection = New SqlConnection(Helper.ConnectionString) Dim cmd As SqlCommand = New SqlCommand cmd.connection = con Dim name As String = txtname.text.replace("'", "''") Dim salary As Decimal = Decimal.Parse(txtSalary.Text) cmd.commandtext = "Update Emp set EmpName='" + txtname.text + "', EmpSalary=" + txtsalary.text + " where EmpId=" + txtid.text MessageBox.Show(cmd.CommandText) cmd.commandtype = CommandType.Text con.open() cmd.executenonquery() MessageBox.Show("Updated...") con.close() End Sub Code: VB Delete button click event private void btndelete_click(object sender, EventArgs e) SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.connection = con; string name = txtname.text.replace("'", "''"); decimal salary = decimal.parse(txtsalary.text); cmd.commandtext = "Update Emp set EmpName='" + txtname.text + "', EmpSalary=" + txtsalary.text + " where EmpId=" + txtid.text; MessageBox.Show(cmd.CommandText); cmd.commandtype = CommandType.Text; cmd.executenonquery(); MessageBox.Show("Updated..."); con.close(); Code: C# 10

11 Fetching Data from Database Select Statement SqlDataReader When Select or similar type of sql statement is executed a new cursor (memory area in backend) is created on the back end. This Cursor contains primary key or indexed key of the table on which the statement is executed for the records which have qualified the condition in the where clause of the select statement. It also has a pointer, which is by default positioned at BOF. The cursor and pointers functionality is encapsulated by the DataReader object created in the front end. Using this object, we can move the pointer in the forward direction getting one record from backend into the frontend at the time. The cursor managed by Data Reader is read-only and forward-only To Get all the records of the Employee table: Private Sub btngetallemps_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btngetallemps.click Dim con As New SqlConnection con.connectionstring = Helper.ConnectionString Dim cmd As New SqlCommand() cmd.connection = con cmd.commandtype = CommandType.Text cmd.commandtext = "Select * from Emp" Dim dr As SqlDataReader con.open() dr = cmd.executereader() Dim str As String = "" While (dr.read()) str &= dr(0).tostring() & vbtab Dim indname As Integer indname = dr.getordinal("empname") str &= dr.getstring(indname) & vbtab Dim indsalary As Integer indsalary = dr.getordinal("empsalary") If (dr.isdbnull(indsalary)) Then str &= vbcrlf Else str &= dr.getdecimal(indsalary) & vbcrlf End If End While dr.close() : con.close() MsgBox(str) End Sub 11

12 Code: VB To Get all the records of the Employee table: private void btngetallemps_click(object sender, EventArgs e) SqlConnection con = new SqlConnection(); con.connectionstring = Helper.ConnectionString; SqlCommand cmd = new SqlCommand("Select * from Emp", con); cmd.commandtype = CommandType.Text; SqlDataReader dr = cmd.executereader(); string str = ""; while (dr.read()) //Read return false when the pointer on the cursor has reached EOF str += dr[0].tostring() + "\t"; int indname = dr.getordinal("empname"); str += dr.getstring(indname) +"\t"; int indsalary = dr.getordinal("empsalary"); if (dr.isdbnull(indsalary)) str += "----\n"; else str += dr.getdecimal(indsalary) + "\n"; dr.close(); con.close(); MessageBox.Show(str); Code: C# Note: It is recommended to use the GetX (X is datatype for example GetInt32()) methods for fetching data from the datareader because here we don t have to cast unlike in case of using indexed property which returns Object and has to be casted Example: To Verify Username and Password Validity Create a table: UserProfile(PKUserId, UserName, Password) Login click event private void btnlogin_click(object sender, EventArgs e) 12

13 SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.connection = con; cmd.commandtext = "Select PKUserId, Password From UserProfile where Username='" + txtusername.text + "'"; SqlDataReader dr = cmd.executereader(); if (!dr.read() dr["password"].tostring()!= txtpassword.text) MessageBox.Show("Invalid u/p"); else MessageBox.Show("Valid - UserId=" + dr["pkuserid"]); con.close(); Code: C# Login click event Private Sub btnlogin_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.click Dim con As New SqlConnection(Helper.ConnectionString) Dim cmd As New SqlCommand() cmd.connection = con cmd.commandtext = "Select PKUserId, Password From UserProfile where Username='" + txtusername.text + "'" con.open() Dim dr As SqlDataReader = cmd.executereader() If ((dr.read()) OrElse (dr("password").tostring() <> txtpassword.text)) Then MessageBox.Show("Invalid u/p"); Else MessageBox.Show("Valid - UserId=" & dr("pkuserid")) End If con.close() End Sub Code: VB 13

14 MARS (Important for Interviews) By Default we can have only one data reader opened at a time on one connection object. If MultipleActiveResultSets=True is added to the connection string then more than one data reader can be opened at the same time on the single connection object. It s a feature in Ado.net 2.0 Department (DeptId, DeptName) Employee (EmpId, EmpName, EmpSalary, DeptId) Getting employees from a department Private Sub btngetdeptemp_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btngetdeptemp.click Dim con As New SqlConnection con.connectionstring = "Data Source=.\sqlexpress;Initial Catalog=MSNETDemoDb;Integrated Security=TRUE; MultipleActiveResultSets=True" Dim cmddept As New SqlCommand cmddept.commandtext = "Select * from Department" cmddept.commandtype = CommandType.Text cmddept.connection = con Dim drdept As SqlDataReader con.open() drdept = cmddept.executereader() Dim str As String = "" While (drdept.read()) Dim cmdemp As New SqlCommand cmdemp.commandtext = "Select * from Employee where Deptid=" & drdept("deptid") cmdemp.commandtype = CommandType.Text cmdemp.connection = con Dim dremp As SqlDataReader dremp = cmdemp.executereader()'this line fails if MARS is not mentioned in connection string. While (dremp.read()) str &= drdept("deptname") & vbtab str &= dremp("empid") & vbtab str &= dremp(1) & vbtab str &= dremp.getdecimal(2) & vbcrlf End While dremp.close() End While drdept.close() MsgBox(str) con.close() 14

15 End Sub Code: VB Getting employees from a department private void btngetallemps_click(object sender, EventArgs e) SqlConnection con = new SqlConnection(); con.connectionstring = "Data Source=.\\sqlexpress;Initial Catalog=MSNETDemoDb;Integrated Security=TRUE; MultipleActiveResultSets = true"; SqlCommand cmddept = new SqlCommand(); cmddept.commandtext = "Select * from Department"; cmddept.commandtype = CommandType.Text; cmddept.connection = con; SqlDataReader drdept; drdept = cmddept.executereader(); string str = ""; while (drdept.read()) SqlCommand cmdemp = new SqlCommand(); cmdemp.commandtext = ("Select * from Employee where Deptid=" + drdept["deptid"]); cmdemp.commandtype = CommandType.Text; cmdemp.connection = con; SqlDataReader dremp; //This line fails if MARS is not mentioned in connection string dremp = cmdemp.executereader(); while(dremp.read()) str += drdept["deptname"].tostring() + '\t'; str += dremp["empid"].tostring() + '\t'; str += dremp[1].tostring() + '\t'; str += dremp.getdecimal(2) + "\r\n"; dremp.close(); drdept.close(); MessageBox.Show(str); con.close(); Code: C# 15

16 Parameterized Prepared Statement Sql Statement on its first execution is compiled, optimized and an execution plan is created for it. If the statement is marked as prepared then for further usage this execution plan is cached by the backend, so that the same plan can be reused for the subsequent request for the same statement but different data. Note: The prepared statement must be framed using the parameters. But every parameterized statement need not be prepared. Program to display command line argument values Class Emp Public Name As String Public Salary As Decimal Public Sub New(ByVal name As String, ByVal salary As Decimal) Me.Name = name Me.Salary = salary End Sub End Class Code: VB Program to display command line argument values class Emp public string Name; public Decimal Salary; public Emp(string name, Decimal salary) this.name = name; this.salary = salary; Code: C# Procedure to execute a Prepared statement 1. Create a Connection object and set its ConnectionString Property 2. Create a Command object and set its Connection, CommandType and CommandText Properties. 3. The CommandText must include place holders for the parameters 4. For every placeholder in the statement, create a Parameter Object. 5. Add all the parameters to the Parameters collection of command object. 6. Open the Connection 7. Prepare the execution plan using Prepare() method of command object. 8. Set the values for parameters and Execute the Command 16

17 9. Repeat step 8 for different values of parameters 10. Close the connection. Program to Execute Insert Statement as Prepared statement Dim con As New SqlConnection(Helper.ConnectionString) Dim cmd As New SqlCommand cmd.connection = con cmd.commandtype = CommandType.Text cmd.commandtext = "Insert into Emp(EmpName, EmpSalary Values Dim parempname As SqlParameter parempname = New SqlParameter("@EmpName", SqlDbType.VarChar, 50) Dim parempsalary As SqlParameter parempsalary = cmd.createparameter() parempsalary.parametername = "@EmpSalary" parempsalary.sqldbtype = SqlDbType.Money cmd.parameters.add(parempname) cmd.parameters.add(parempsalary) Dim lstemps As New List(Of Emp) lstemps.add(new Emp("DE1", 10000)) lstemps.add(new Emp("DE2", 20000)) lstemps.add(new Emp("DE3", 30000)) lstemps.add(new Emp("DE4", 20000)) con.open() cmd.prepare() 'Prepares the execution plan For Each emp As Emp In lstemps parempname.value = emp.name parempsalary.value = emp.salary cmd.executenonquery() 'The prepared execution plan is used here Next con.close() Code: VB Program to Execute Insert Statement as Prepared statement SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.connection = con; cmd.commandtype = CommandType.Text; cmd.commandtext = "Insert into Emp(EmpName, EmpSalary Values SqlParameter parempname; parempname = new SqlParameter("@EmpName", SqlDbType.VarChar, 50); 17

18 SqlParameter parempsalary; parempsalary = cmd.createparameter(); parempsalary.parametername = "@EmpSalary"; parempsalary.sqldbtype = SqlDbType.Money; cmd.parameters.add(parempname); cmd.parameters.add(parempsalary); List lstemps = new List(Of, Emp); lstemps.add(new Emp("DE1", 10000)); lstemps.add(new Emp("DE2", 20000)); lstemps.add(new Emp("DE3", 30000)); lstemps.add(new Emp("DE4", 20000)); cmd.prepare(); // Prepares the execution plan foreach (Emp emp in lstemps) parempname.value = emp.name; parempsalary.value = emp.salary; cmd.executenonquery(); // The prepared execution plan is used here& con.close(); Code: C# 1. In Sql Server the parameters must begin In Oracle just the name is sufficient but for OleDb and Odbc Providers we need to use? as place holder for all the parameters and while adding the parameters a proper order must be maintained. 2. If the SQL Statement has to be executed only once, don t mark as Prepared because the backend takes extra time for preparation of execution plan and this would become overhead the plan is not reused. 3. If the parameter is of type varchar or string and if the value of it has single quote, don t replace that single quote with two single quotes (unlike in a simple statement with data directly embed into it). Inserting and reading Images: Create table TestBlob ( imphoto image not null ) Inserting Image into database: FileStream fs = new FileStream (textbox1.text, FileMode.Open, FileAccess.Read); byte[] rawbyte = new byte[fs.length]; 18

19 fs.read (rawbyte, 0, fs.rawbyte.length); con.open (); cmd = new SqlCommand ("Insert into TestBlob values(@photo)", con); SqlParameter par = cmd.parameters.addwithvalue ("@photo", SqlDbType.Image); par.value = rawbyte; cmd.executenonquery (); con.close (); Working with Stored Procedures A Stored Procedure is a set of SQL Statement together with some logic Pre-Compiled in native format and saved in the backend. Advantages: 1. They are faster in execution because they are precompiled and stored in backend in native form of that backend. 2. Reduces network traffic because they are executed in backend the data used by them is also in backend. 3. It s easy to update logic/code in them because it s stored only at one place i.e. in database. Sequence of Steps for Executing the Stored Procedure in front end application 1. Create a Connection object and set its ConnectionString Property 2. Create a Command object and set its Connection, CommandType and CommandText Properties. 3. For every parameter in the prepared statement / stored procedure, create a Parameter Object and set its ParameterName, Data Type, Size and Direction properties. 4. Add the Parameters to the Parameters collection of Command Object. 5. Set the value for all Input Parameters. 6. Open the Connection 7. Execute the Command using the appropriate Execute Method. 8. Close the Connection 9. Retrieve the value from output parameters. CREATE PROCEDURE GetSalary(@Id int,@sal money output ) AS Begin from Emp where EmpId=@Id End Note: In SQL Server every OUTPUT parameter is also treated as IN parameter. Example 1: Code to Execute a SP GetSalary Dim con As SqlConnection = New SqlConnection(Helper.ConnectionString) Dim cmd As SqlCommand = New SqlCommand("GetSalary", con) 'GetSalary is name of SP cmd.commandtype = CommandType.StoredProcedure 19

20 Dim parid As SqlParameter = cmd.parameters.add("@id", SqlDbType.Int) Dim parsalary As SqlParameter = cmd.parameters.add("@sal", SqlDbType.Money) parsalary.direction = ParameterDirection.Output parid.value = txtid.text con.open cmd.executenonquery con.close If (parsalary.value = DBNull.Value) Then txtsalary.text = "" Else txtsalary.text = parsalary.value.tostring End If Code: VB Example 1: Code to Execute a SP GetSalary SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand("GetSalary", con); //GetSalary is name of SP cmd.commandtype = CommandType.StoredProcedure; SqlParameter parid = cmd.parameters.add("@id", SqlDbType.Int); //Name and Type of Parameter must be same as in SP SqlParameter parsalary = cmd.parameters.add("@sal", SqlDbType.Money); parsalary.direction = ParameterDirection.Output; parid.value = txtid.text; cmd.executenonquery(); con.close(); if (parsalary.value == DBNull.Value) txtsalary.text = ""; else txtsalary.text = parsalary.value.tostring(); Code: C# CREATE PROCEDURE InsertEmp(@Id int money) AS Begin Insert into Emp(EmpName, EmpSalary) values (@Name,@Salary) End 2nd Example: To execute the Stored Procedure - InsertEmp 20

21 Dim con As SqlConnection = New SqlConnection(Helper.ConnectionString) Dim cmd As SqlCommand = New SqlCommand("InsertEmp", con) cmd.commandtype = CommandType.StoredProcedure Dim parsalary As SqlParameter parid = cmd.parameters.add("@id", SqlDbType.Int) parid.direction = ParameterDirection.Output parname = cmd.parameters.add("@name", SqlDbType.VarChar, 50) parsalary = cmd.parameters.add("@salary", SqlDbType.Money) parname.value = txtname.text parsalary.value = txtsalary.text con.open() cmd.executenonquery() con.close() txtid.text = parid.value.tostring Code: VB 2nd Example: To execute the Stored Procedure - InsertEmp SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand("InsertEmp", con); cmd.commandtype = CommandType.StoredProcedure; SqlParameter parid, parname, parsalary; parid = cmd.parameters.add("@id", SqlDbType.Int); parid.direction = ParameterDirection.Output; parname = cmd.parameters.add("@name", SqlDbType.VarChar, 50); parsalary = cmd.parameters.add("@salary", SqlDbType.Money); parname.value = txtname.text; parsalary.value = txtsalary.text; cmd.executenonquery(); con.close(); txtid.text = parid.value.tostring(); Code: C# Create Procedure GetEmployees AS Begin Select Count(*) from Emp Select EmpId, EmpName, EmpSalary from Emp End 3rd Example: Code to Execute the SP - GetEmployees 21

22 Dim con As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=MSDemoDb;Integrated Security=TRUE") Dim cmd As New SqlCommand cmd.commandtext = "GetEmployees" cmd.commandtype = CommandType.StoredProcedure cmd.connection = con con.open() Dim dr As SqlDataReader = cmd.executereader() dr.read() 'Moves to the only record in the first cursor created by execution of the stored procedure. MsgBox(dr(0)) 'Shows the total number of records in the Emp table.- i.e result of Select Count(*) from Emp dr.nextresult() 'Moves the Pointer to the second cursor. i.e Select EmpId, EmpName, EmpSalary from Emp Dim str As String = "" While (dr.read()) str &= dr("empid") & vbtab str &= dr(1) & vbtab Dim ind As Integer ind = dr.getordinal("empsalary") 'Return the Index of the column EmpSalary If (dr.isdbnull(ind)) Then str &= "--" & vbcrlf Else str &= dr.getdecimal(ind) & vbcrlf End If End While MsgBox(str) dr.close() con.close() Code: VB 3rd Example: Code to Execute the SP - GetEmployees SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=MSDemoDb;Integrated Security=TRUE"); SqlCommand cmd = new SqlCommand(); cmd.commandtext = "GetEmployees"; cmd.commandtype = CommandType.StoredProcedure; cmd.connection = con; SqlDataReader dr = cmd.executereader(); dr.read(); // Moves to the only record in the first cursor created by execution of the stored procedure. MessageBox.Show(dr[0].ToString()); 22

23 // Shows the total number of records in the Emp table.- i.e result of _Select Count(*) from Emp_ dr.nextresult(); string str = ""; while (dr.read()) str += dr["empid"].tostring() + '\t'; str += dr[1].tostring() + '\t'; int ind; ind = dr.getordinal("empsalary"); // Return the Index of the column EmpSalary if (dr.isdbnull(ind)) str += "--" + "\r\n"; else str += dr.getdecimal(ind) + "\r\n"; MessageBox.Show(str); dr.close(); con.close(); Code: C# Note: If required cmd.commandtext can have more than one sql statement separated by ;. This feature may not be supported by all databases. Working with Transactions Definition: It s a group of Sql Statements to be executed as one unit to modify the state of database. Backend is responsible for managing the transactions. To bind all the Command objects to a single Transaction do the following 1. On the Connection object begin the transaction (con.begintransaction), this returns the reference to the Transaction object (trans) encapsulating transaction created in the backend. 2. All the Command objects, Transaction Property must be set to the above Transaction object. 3. In Try block execute all the Commands 4. If the exception is not thrown the last statement of the try must Commit (trans.commit())the transaction, but if the exception is thrown the Catch must execute Rollback (trans.rollback()) on the transaction object. Step1: Create Account(AccountID, Balance) table in backend. Step2: Add constraint Balance >=

24 Step3: Write the following code in button click Transaction Example SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmdsource = new SqlCommand(); cmdsource.commandtext = "Update Account Set Balance = Balance - " + txtamount.text + " where AccountId=1"; cmdsource.connection = con; SqlCommand cmdtarget = new SqlCommand(); cmdtarget.commandtext = "Update Account Set Balance = Balance + " + txtamount.text + " where AccountId=2"; cmdtarget.connection = con; SqlTransaction trans = con.begintransaction(); cmdtarget.transaction = trans; cmdsource.transaction = trans; try cmdtarget.executenonquery(); cmdsource.executenonquery(); trans.commit(); catch (SqlException ex) trans.rollback(); MessageBox.Show(ex.Message); con.close(); Code: C# Note: Once a transaction has begun over a connection, a command without its transaction property set, cannot be executed on that connection unless either the transaction is committed or rolledback. Managing Transaction using TransactionScope 1. Add reference to System.Transactions 2. On top of file mention using System.Transactions (CS) or Imports System.Transactions (VB). 3. Enclose the block of code for execution of all commands in using block of TransactionScope object as below Transactions in ADO.net 2.0 using System.Transactions; SqlConnection con1 = new SqlConnection(Helper.ConnectionString); SqlConnection con2 = con1;// new SqlConnection(Helper.ConnectionString); SqlCommand cmdsource = new SqlCommand(); cmdsource.commandtext = "Update Account Set Balance = Balance - " + txtamount.text + " where AccountId=1"; cmdsource.connection = con1; SqlCommand cmdtarget = new SqlCommand(); 24

25 cmdtarget.commandtext = "Update Account Set Balance = Balance + " + txtamount.text + " where AccountId=2"; cmdtarget.connection = con2; using (TransactionScope ts = new TransactionScope()) con1.open(); // con2.open(); cmdtarget.executenonquery(); cmdsource.executenonquery(); con1.close(); //con2.close(); ts.complete(); Code: C# Advantage of using this over con.begintransaction: TransactionScope can encapsulate Distributed Transactions (while using more than one database) i.e. within TransactionScope all the commands executed fall under one transaction irrespective of their Connection (which can be same or different) Asynchronous Execution of SQL Commands BeginX / EndX Methods (Until Framework 4.0) OR XAsync Methods (from Framework 4.5) Step1: Create the Following Stored Procedure Create Procedure GetAllEmployees as Begin WAITFOR DELAY '00:00:10' --delay for 10secs Select * from Emp End Step2: Use any one of the following techniques: Async Execution using BeginX and EndX methods SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand("GetAllEmployees", con); cmd.commandtype = CommandType.StoredProcedure; IAsyncResult ar = cmd.beginexecutereader(); MessageBox.Show("Continue..."); while (!ar.iscompleted) Application.DoEvents(); SqlDataReader dr = cmd.endexecutereader(ar); 25

26 string str = ""; while (dr.read()) str += dr[0] + "\n"; dr.close(); con.close(); MessageBox.Show(str); Code: C# Async Execution using Async Methods and wait keyword private async void btnasyncusingasyncandwaitkeywords_click(object sender, EventArgs e) SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand("GetAllEmployees", con); cmd.commandtype = CommandType.StoredProcedure; SqlDataReader dr = await cmd.executereaderasync(); string str = ""; while (dr.read()) str += dr[0] + "\n"; con.close(); MessageBox.Show(str); Using Factory class for writing Provider Independent code How can we write code which is not directly using any provider specific classes and most of the things are done using interface? Namespace: System.Data.Common has the required Factory classes for doing the same. Program to display command line argument values Private Sub btnselectemployees_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnselectemployees.click Dim fac As System.Data.Common.DbProviderFactory fac = System.Data.Common.DbProviderFactories.GetFactory("System.Data.SqlClient") Dim con As IDbConnection = fac.createconnection con.connectionstring = Helper.ConnectionString Dim cmd As IDbCommand = fac.createcommand cmd.commandtext = "Select * from Emp" cmd.connection = con con.open() Dim dr As IDataReader = cmd.executereader Dim str As String = "" 26

27 While dr.read Dim indempid As Integer = dr.getordinal("empid") str = (str _ + (dr.getint32(indempid) + "" & vbtab)) Dim indempname As Integer = dr.getordinal("empname") str = (str _ + (dr.getstring(indempname) + "" & vbtab)) Dim indempsalary As Integer = dr.getordinal("empsalary") If dr.isdbnull(indempsalary) Then str = (str + "" & vblf) Else str = (str _ + (dr.getdecimal(indempsalary) + "" & vblf)) End If End While dr.close() con.close() MessageBox.Show(str) End Sub Code: VB Program to display command line argument values private void btnselectemployees_click(object sender, EventArgs e) System.Data.Common.DbProviderFactory fac; fac = System.Data.Common.DbProviderFactories.GetFactory("System.Data.SqlClient"); IDbConnection con = fac.createconnection(); con.connectionstring = Helper.ConnectionString; IDbCommand cmd = fac.createcommand(); cmd.commandtext = "Select * from Emp"; cmd.connection = con; IDataReader dr = cmd.executereader(); string str = ""; while (dr.read()) int indempid = dr.getordinal("empid"); str += dr.getint32(indempid) + "\t"; int indempname = dr.getordinal("empname"); str += dr.getstring(indempname) + "\t"; 27

28 int indempsalary = dr.getordinal("empsalary"); if (dr.isdbnull(indempsalary)) str += "\n"; else str += dr.getdecimal(indempsalary) + "\n"; dr.close(); con.close(); MessageBox.Show(str); Code: C# How Generic code can be written Example for execution of Stored Procedure Program to show usage of Stored Procedure Class DBUtil Public Shared Function ExecuteSPNonQuery(ByVal spname As String, ByVal ParamArray params() As SqlParameter) As Integer Dim con As New SqlConnection(Helper.ConnectionString) Dim cmd As New SqlCommand(spName, con) cmd.commandtype = CommandType.StoredProcedure cmd.parameters.addrange(params) Try con.open() Return cmd.executenonquery() Finally con.close() End Try End Function Public Shared Function ExecuteSPDataReader(ByVal spname As String, ByVal ParamArray params() As SqlParameter) As SqlDataReader Dim con As New SqlConnection(Helper.ConnectionString) Dim cmd As New SqlCommand(spName, con) cmd.commandtype = CommandType.StoredProcedure For Each p As SqlParameter In params cmd.parameters.add(p) Next con.open() Return cmd.executereader(commandbehavior.closeconnection) Because CommandBehavior.CloseConnection is used as parameter for ExecureReader the 28

29 Connection will be automatically closed when the DataReader returned to the calling method is closed. End Function End Class Private Sub btnexecutesp_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnexecutesp.click Dim cs As String = "server=.\sqlexpress;database=msnet;integrated security=true" Dim spname As String = "GetSalary" Dim pid As SqlParameter = New SqlParameter("@Id", SqlDbType.Int) pid.direction = ParameterDirection.Input Dim psalary As SqlParameter = New SqlParameter("@sal", SqlDbType.Money) psalary.direction = ParameterDirection.Output pid.value = CInt(txtId.Text) DBUtil.ExecuteSPNonQuery(cs, spname, pid, psalary) If (Not IsDBNull(pSalary.Value)) Then txtsalary.text = psalary.value End If End Sub Code: VB Program to show usage of Stored Procedure class DBUtil public static int ExecuteSPNonQuery(string spname, params SqlParameter[] params1) SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand(spName, con); cmd.commandtype = CommandType.StoredProcedure; cmd.parameters.addrange(params1); try return cmd.executenonquery(); finally con.close(); public static SqlDataReader ExecuteSPDataReader(string spname, params SqlParameter[] params1) 29

30 SqlConnection con = new SqlConnection(Helper.ConnectionString); SqlCommand cmd = new SqlCommand(spName, con); cmd.commandtype = CommandType.StoredProcedure; foreach (SqlParameter p in params1) cmd.parameters.add(p); return cmd.executereader(commandbehavior.closeconnection); private void btnexecutesp_click(object sender, System.EventArgs e) IDataReader reader; string cs = "server=.\\sqlexpress;database=msnet;integrated security=true"; string spname = "GetSalary"; SqlParameter pid = new SqlParameter("@Id", SqlDbType.Int); pid.direction = ParameterDirection.Input; SqlParameter psalary = new SqlParameter("@sal", SqlDbType.Money); psalary.direction = ParameterDirection.Output; pid.value = int.parse(txtid.text); DBUtil.ExecuteSPNonQuery(spName, pid, psalary); if (psalary.value!=null) txtsalary.text = psalary.value; Code: C# 30

31 Quick Overview of API Covered in this Chapter Important Members of SqlConnection: Properties: ConnectionString Methods: Open, Close, BeginTransaction Important Members of SqlCommand: Properties: Connection, CommandType, CommandText, Parameters Methods: ExecuteNonQuery, ExecuteScalar, ExecuteReader, CreateParameter, Prepare ExecuteNonQueryAsync, ExecuteScalarAsync, ExecuteReaderAsync BeginExecuteNonQuery, BegingExecuteReader EndExecuteNonQuery, EndExecuteReader Important Members of SqlDataReader: Properties: IndexProperty - [ ] Methods: Read, GetOrdinal, GetInt32, GetString..GetX (X is datatype), IsDbNull,Close, HasRows Important Members of SqlParameter: Properties: Value, ParameterName, SqlDbType, Size, Direction Methods: Important Members of SqlTransaction: Properties: Methods: Commit, Rollback TransactionScope: Complete() Summary: In this section we have studied ADO.NET managed providers, writing a sample application to test connection, different ways of SQL Command Execution methods, Multiple Active Record Sets, using prepared statement, Stored Procedures, Transaction and Factory class. 31

ASP.NET Programming with C# and SQL Server

ASP.NET Programming with C# and SQL Server ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET Objectives In this chapter, you will: Connect to SQL Server from ASP.NET Learn how to handle

More information

AD A O.N. ET E Access Data Object

AD A O.N. ET E Access Data Object ADO.NET Access Data Object ADO.NET Conjunto de classes que permitem o acesso à base de dados. Dois cenários: Connected Os dados provenientes da base de dados são obtidos a partir de uma ligação que se

More information

Deleting A Record... 26 Updating the Database... 27 Binding Data Tables to Controls... 27 Binding the Data Table to the Data Grid View...

Deleting A Record... 26 Updating the Database... 27 Binding Data Tables to Controls... 27 Binding the Data Table to the Data Grid View... 1 Table of Contents Chapter 9...4 Database and ADO.NET...4 9.1 Introduction to Database...4 Table Definitions...4 DDL and DML...5 Indexes, the Primary Key, and the Foreign Key...5 Index Uniqueness...5

More information

ADOBE READER AND ACROBAT

ADOBE READER AND ACROBAT ADOBE READER AND ACROBAT IFILTER CONFIGURATION Table of Contents Table of Contents... 1 Overview of PDF ifilter 11 for 64-bit platforms... 3 Installation... 3 Installing Adobe PDF IFilter... 3 Setting

More information

A Tutorial on SQL Server 2005. CMPT 354 Fall 2007

A Tutorial on SQL Server 2005. CMPT 354 Fall 2007 A Tutorial on SQL Server 2005 CMPT 354 Fall 2007 Road Map Create Database Objects Create a database Create a table Set a constraint Create a view Create a user Query Manage the Data Import data Export

More information

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Bertrand Meyer. C#: Persistence

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Bertrand Meyer. C#: Persistence Chair of Software Engineering Carlo A. Furia, Bertrand Meyer C#: Persistence Outline C# Serialization Connecting to a RDBMS with ADO.NET LINQ (Language Integrated Queries) NoSQL Solutions for C# and Java

More information

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code. Content Introduction... 2 Data Access Server Control Panel... 2 Running the Sample Client Applications... 4 Sample Applications Code... 7 Server Side Objects... 8 Sample Usage of Server Side Objects...

More information

Using IRDB in a Dot Net Project

Using IRDB in a Dot Net Project Note: In this document we will be using the term IRDB as a short alias for InMemory.Net. Using IRDB in a Dot Net Project ODBC Driver A 32-bit odbc driver is installed as part of the server installation.

More information

How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET

How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET See also: http://support.businessobjects.com/communitycs/technicalpapers/rtm_reporting offadonetdatasets.pdf http://www.businessobjects.com/products/dev_zone/net_walkthroughs.asp

More information

VB.NET - DATABASE ACCESS

VB.NET - DATABASE ACCESS VB.NET - DATABASE ACCESS http://www.tutorialspoint.com/vb.net/vb.net_database_access.htm Copyright tutorialspoint.com Applications communicate with a database, firstly, to retrieve the data stored there

More information

5 Airport. Chapter 5: Airport 49. Right-click on Data Connections, then select Add Connection.

5 Airport. Chapter 5: Airport 49. Right-click on Data Connections, then select Add Connection. Chapter 5: Airport 49 5 Airport Most practical applications in C# require data to be stored in a database and accessed by the program. We will examine how this is done by setting up a small database of

More information

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO: INTRODUCTION: You can extract data (i.e. the total cost report) directly from the Truck Tracker SQL Server database by using a 3 rd party data tools such as Excel or Crystal Reports. Basically any software

More information

ODBC Client Driver Help. 2015 Kepware, Inc.

ODBC Client Driver Help. 2015 Kepware, Inc. 2015 Kepware, Inc. 2 Table of Contents Table of Contents 2 4 Overview 4 External Dependencies 4 Driver Setup 5 Data Source Settings 5 Data Source Setup 6 Data Source Access Methods 13 Fixed Table 14 Table

More information

CRM Setup Factory Installer V 3.0 Developers Guide

CRM Setup Factory Installer V 3.0 Developers Guide CRM Setup Factory Installer V 3.0 Developers Guide Who Should Read This Guide This guide is for ACCPAC CRM solution providers and developers. We assume that you have experience using: Microsoft Visual

More information

CRYSTAL REPORTS IN VISUAL STUDIO.NET 2003

CRYSTAL REPORTS IN VISUAL STUDIO.NET 2003 CRYSTAL REPORTS IN VISUAL STUDIO.NET 2003 By Srunokshi Kaniyur Prema Neelakantan This tutorial gives an introduction to creating Crystal reports in Visual Studio.Net 2003 and few of the features available

More information

Database Programming with C# CARSTEN THOMSEN

Database Programming with C# CARSTEN THOMSEN Database Programming with C# CARSTEN THOMSEN Database Programming with C# Copyright 2002 by Carsten Thomsen All rights reserved. No part of this work may be reproduced or transmitted in any form or by

More information

Aplicação ASP.NET MVC 4 Usando Banco de Dados

Aplicação ASP.NET MVC 4 Usando Banco de Dados Aplicação ASP.NET MVC 4 Usando Banco de Dados Neste exemplo simples, vamos desenvolver uma aplicação ASP.NET MVC para acessar o banco de dados Northwind, que está armazenado no servidor SQL Server e, listar

More information

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach TRAINING & REFERENCE murach's SQL Server 2012 for developers Bryan Syverson Joel Murach Mike Murach & Associates, Inc. 4340 N. Knoll Ave. Fresno, CA 93722 www.murach.com murachbooks@murach.com Expanded

More information

C# Datenbank-Programmierung

C# Datenbank-Programmierung C# Datenbank-Programmierung Usings... 2 Verbindung herstellen SQL und Acces... 2 Verbindung schliessen SQL und Acces... 3 File open Dialog... 3 Lehar einfügen... 3 Lehar löschen... 4 Radio Button SQL &

More information

Guide to Upsizing from Access to SQL Server

Guide to Upsizing from Access to SQL Server Guide to Upsizing from Access to SQL Server An introduction to the issues involved in upsizing an application from Microsoft Access to SQL Server January 2003 Aztec Computing 1 Why Should I Consider Upsizing

More information

How to Connect to CDL SQL Server Database via Internet

How to Connect to CDL SQL Server Database via Internet How to Connect to CDL SQL Server Database via Internet There are several different methods available for connecting to the CDL SQL Server. Microsoft Windows has built in tools that are very easy to implement

More information

Mastering Visual Basic.NET Database Programming Evangelos Petroutsos; Asli Bilgin

Mastering Visual Basic.NET Database Programming Evangelos Petroutsos; Asli Bilgin SYBEX Sample Chapter Mastering Visual Basic.NET Database Programming Evangelos Petroutsos; Asli Bilgin Chapter 6: A First Look at ADO.NET Copyright 2002 SYBEX Inc., 1151 Marina Village Parkway, Alameda,

More information

Building ASP.NET Applications

Building ASP.NET Applications white paper Building ASP.NET Applications with Delphi and Advantage Database Server by Cary Jensen www.sybase.com/ianywhere TABLE OF CONTENTS X Abstract 2 Getting Started 5 The Primary Classes of the Advantage

More information

SQL Injection. The ability to inject SQL commands into the database engine through an existing application

SQL Injection. The ability to inject SQL commands into the database engine through an existing application SQL Injection The ability to inject SQL commands into the database engine through an existing application 1 What is SQL? SQL stands for Structured Query Language Allows us to access a database ANSI and

More information

1. La classe Connexion class Connexion {

1. La classe Connexion class Connexion { 1. La classe Connexion class Connexion public static string chaine; IDbConnection cnx; IDbCommand cmd; IDataReader dr; private string chainesqlserver = "Data Source=localhost;Initial catalog=reservations;

More information

Using the SQL Server Linked Server Capability

Using the SQL Server Linked Server Capability Using the SQL Server Linked Server Capability SQL Server s Linked Server feature enables fast and easy integration of SQL Server data and non SQL Server data, directly in the SQL Server engine itself.

More information

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically Normalization of databases Database normalization is a technique of organizing the data in the database. Normalization is a systematic approach of decomposing tables to eliminate data redundancy and undesirable

More information

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package 7 2015-11-24. Data Federation Administration Tool Guide

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package 7 2015-11-24. Data Federation Administration Tool Guide SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package 7 2015-11-24 Data Federation Administration Tool Guide Content 1 What's new in the.... 5 2 Introduction to administration

More information

MS Enterprise Library 5.0 (Logging Application Block)

MS Enterprise Library 5.0 (Logging Application Block) International Journal of Scientific and Research Publications, Volume 4, Issue 8, August 2014 1 MS Enterprise Library 5.0 (Logging Application Block) Anubhav Tiwari * R&D Dept., Syscom Corporation Ltd.

More information

How to test and debug an ASP.NET application

How to test and debug an ASP.NET application Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult

More information

Empirical study of performance of data binding in ASP.NET web applications

Empirical study of performance of data binding in ASP.NET web applications Empirical study of performance of data binding in ASP.NET web applications Toni Stojanovski 1, Marko Vučković 1, and Ivan Velinov 1 1 Faculty of Informatics, European University, Skopje, Republic of Macedonia,

More information

1 of 8 16/08/2004 11:19 AM

1 of 8 16/08/2004 11:19 AM 1 of 8 16/08/2004 11:19 AM See This in MSDN Library Generic Coding with the ADO.NET 2.0 Base Classes and Factories Bob Beauchemin DevelopMentor July 2004 Applies to: Microsoft ADO.NET 2.0 Microsoft Visual

More information

Architecting the Future of Big Data

Architecting the Future of Big Data Hive ODBC Driver User Guide Revised: July 22, 2014 2012-2014 Hortonworks Inc. All Rights Reserved. Parts of this Program and Documentation include proprietary software and content that is copyrighted and

More information

Getting Started with STATISTICA Enterprise Programming

Getting Started with STATISTICA Enterprise Programming Getting Started with STATISTICA Enterprise Programming 2300 East 14th Street Tulsa, OK 74104 Phone: (918) 749 1119 Fax: (918) 749 2217 E mail: mailto:developerdocumentation@statsoft.com Web: www.statsoft.com

More information

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Database 10g Edition: All possible 10g features, either bundled or available at additional cost. Concepts Oracle Corporation offers a wide variety of products. The Oracle Database 10g, the product this exam focuses on, is the centerpiece of the Oracle product set. The "g" in "10g" stands for the Grid

More information

How to Create Database in Microsoft Excel 2003

How to Create Database in Microsoft Excel 2003 Step 1: Getting start How to Create Database in Microsoft Excel 2003 Install Microsoft Excel 2000 or 2003 in your computer, press start program files click Microsoft Excel 2003 After click MS-Excel it

More information

FileMaker 14. ODBC and JDBC Guide

FileMaker 14. ODBC and JDBC Guide FileMaker 14 ODBC and JDBC Guide 2004 2015 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker and FileMaker Go are trademarks of FileMaker,

More information

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute JMP provides a variety of mechanisms for interfacing to other products and getting data into JMP. The connection

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along

More information

Beginning MYSQL 5.0. With. Visual Studio.NET 2005

Beginning MYSQL 5.0. With. Visual Studio.NET 2005 Beginning MYSQL 5.0 With Visual Studio.NET 2005 By Anil Mahadev Database Technologist and Enthusiast Welcome to the Wonderful of MYSQL 5, a phenomenal release in the History of MYSQL Development. There

More information

Accessing Database Information Using Visual Basic:

Accessing Database Information Using Visual Basic: Accessing Database Information Using Visual Basic: Data Access Objects and Remote Data Objects Amanda Reynolds Y398--Internship June 23, 1999 Abstract * Data Access Objects * Declaring a Data Bound Control

More information

HOW-TO. Access Data using BCI. Brian Leach Consulting Limited. http://www.brianleach.co.uk

HOW-TO. Access Data using BCI. Brian Leach Consulting Limited. http://www.brianleach.co.uk HOW-TO Access Data using BCI http://www.brianleach.co.uk Contents Introduction... 3 Notes... 4 Defining the Data Source... 5 Check the Definition... 7 Setting up the BCI connection... 8 Starting with BCI...

More information

Architecting the Future of Big Data

Architecting the Future of Big Data Hive ODBC Driver User Guide Revised: July 22, 2013 2012-2013 Hortonworks Inc. All Rights Reserved. Parts of this Program and Documentation include proprietary software and content that is copyrighted and

More information

CounterPoint SQL and Magento ecommerce Interface

CounterPoint SQL and Magento ecommerce Interface CounterPoint SQL and Magento ecommerce Interface Requirements: CounterPoint SQL: 8.3.9, 8.4.2 Magento Community Edition: 1.5.1+ (older versions are not compatible due to changes in Magento s API) MagentoGo

More information

DBQT - Database Query Tool Manual 1/11. Manual DBQT. Database Query Tool. Document Version: 08-03-17. 2008 unu.ch

DBQT - Database Query Tool Manual 1/11. Manual DBQT. Database Query Tool. Document Version: 08-03-17. 2008 unu.ch 1/11 DBQT Database Query Tool Document Version: 08-03-17 2/11 Table of Contents 1. INTRODUCTION... 3 2. SYSTEM REQUIREMENTS... 3 3. GRAPHICAL USER INTERFACE... 4 3.1 MENU BAR... 4 3.2 DATABASE OBJECTS

More information

How To Create A Database In Araba

How To Create A Database In Araba create database ARABA use ARABA create table arac ( plaka varchar(15), marka varchar(15), model varchar(4)) create table musteri ( tck varchar(11), ad varchar(15), soy varchar(15)) drop table kiralama

More information

JDBC (Java / SQL Programming) CS 377: Database Systems

JDBC (Java / SQL Programming) CS 377: Database Systems JDBC (Java / SQL Programming) CS 377: Database Systems JDBC Acronym for Java Database Connection Provides capability to access a database server through a set of library functions Set of library functions

More information

Aradial Installation Guide

Aradial Installation Guide Aradial Technologies Ltd. Information in this document is subject to change without notice. Companies, names, and data used in examples herein are fictitious unless otherwise noted. No part of this document

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to

More information

Chapter 4 Accessing Data

Chapter 4 Accessing Data Chapter 4: Accessing Data 73 Chapter 4 Accessing Data The entire purpose of reporting is to make sense of data. Therefore, it is important to know how to access data locked away in the database. In this

More information

BarTender s ActiveX Automation Interface. The World's Leading Software for Label, Barcode, RFID & Card Printing

BarTender s ActiveX Automation Interface. The World's Leading Software for Label, Barcode, RFID & Card Printing The World's Leading Software for Label, Barcode, RFID & Card Printing White Paper BarTender s ActiveX Automation Interface Controlling BarTender using Programming Languages not in the.net Family Contents

More information

Crystal Reports for Visual Studio.NET

Crystal Reports for Visual Studio.NET Overview Contents This document describes how to use Crystal Reports for Visual Studio.NET with ADO.NET. This document also covers the differences between ADO and ADO.NET INTRODUCTION... 2 DIFFERENCES

More information

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led

More information

The JAVA Way: JDBC and SQLJ

The JAVA Way: JDBC and SQLJ The JAVA Way: JDBC and SQLJ David Toman School of Computer Science University of Waterloo Introduction to Databases CS348 David Toman (University of Waterloo) JDBC/SQLJ 1 / 21 The JAVA way to Access RDBMS

More information

Basic Unix/Linux 1. Software Testing Interview Prep

Basic Unix/Linux 1. Software Testing Interview Prep Basic Unix/Linux 1 Programming Fundamentals and Concepts 2 1. What is the difference between web application and client server application? Client server application is designed typically to work in a

More information

FileMaker 11. ODBC and JDBC Guide

FileMaker 11. ODBC and JDBC Guide FileMaker 11 ODBC and JDBC Guide 2004 2010 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker is a trademark of FileMaker, Inc. registered

More information

Oracle to MySQL Migration

Oracle to MySQL Migration to Migration Stored Procedures, Packages, Triggers, Scripts and Applications White Paper March 2009, Ispirer Systems Ltd. Copyright 1999-2012. Ispirer Systems Ltd. All Rights Reserved. 1 Introduction The

More information

Visual Basic Database Programming

Visual Basic Database Programming Ch01 10/29/99 2:27 PM Page 1 O N E Visual Basic Database Programming Welcome to our book on Microsoft Visual Basic and ActiveX Data Objects (ADO) programming. In this book, we re going to see a tremendous

More information

Tutorial: How to Use SQL Server Management Studio from Home

Tutorial: How to Use SQL Server Management Studio from Home Tutorial: How to Use SQL Server Management Studio from Home Steps: 1. Assess the Environment 2. Set up the Environment 3. Download Microsoft SQL Server Express Edition 4. Install Microsoft SQL Server Express

More information

InterBase 6. Embedded SQL Guide. Borland/INPRISE. 100 Enterprise Way, Scotts Valley, CA 95066 http://www.interbase.com

InterBase 6. Embedded SQL Guide. Borland/INPRISE. 100 Enterprise Way, Scotts Valley, CA 95066 http://www.interbase.com InterBase 6 Embedded SQL Guide Borland/INPRISE 100 Enterprise Way, Scotts Valley, CA 95066 http://www.interbase.com Inprise/Borland may have patents and/or pending patent applications covering subject

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle University Contact Us: + 38516306373 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the

More information

Getting Started with Telerik Data Access. Contents

Getting Started with Telerik Data Access. Contents Contents Overview... 3 Product Installation... 3 Building a Domain Model... 5 Database-First (Reverse) Mapping... 5 Creating the Project... 6 Creating Entities From the Database Schema... 7 Model-First

More information

Jet Data Manager 2012 User Guide

Jet Data Manager 2012 User Guide Jet Data Manager 2012 User Guide Welcome This documentation provides descriptions of the concepts and features of the Jet Data Manager and how to use with them. With the Jet Data Manager you can transform

More information

Intro to Embedded SQL Programming for ILE RPG Developers

Intro to Embedded SQL Programming for ILE RPG Developers Intro to Embedded SQL Programming for ILE RPG Developers Dan Cruikshank DB2 for i Center of Excellence 1 Agenda Reasons for using Embedded SQL Getting started with Embedded SQL Using Host Variables Using

More information

Using the SQL TAS v4

Using the SQL TAS v4 Using the SQL TAS v4 Authenticating to the server Consider this MySQL database running on 10.77.0.5 (standard port 3306) with username root and password mypassword. mysql> use BAKERY; Database changed

More information

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming TRAINING & REFERENCE murach's web programming with C# 2010 Anne Boehm Joel Murach Va. Mike Murach & Associates, Inc. I J) 1-800-221-5528 (559) 440-9071 Fax: (559) 44(M)963 murachbooks@murach.com www.murach.com

More information

Commercial Database Software Development- A review.

Commercial Database Software Development- A review. Commercial Database Software Development- A review. A database software has wide applications. A database software is used in almost all the organizations. Over 15 years many tools have been developed

More information

TIBCO Spotfire Metrics Modeler User s Guide. Software Release 6.0 November 2013

TIBCO Spotfire Metrics Modeler User s Guide. Software Release 6.0 November 2013 TIBCO Spotfire Metrics Modeler User s Guide Software Release 6.0 November 2013 Important Information SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED OR BUNDLED TIBCO SOFTWARE

More information

COSC344 Database Theory and Applications. Java and SQL. Lecture 12

COSC344 Database Theory and Applications. Java and SQL. Lecture 12 COSC344 Database Theory and Applications Lecture 12: Java and SQL COSC344 Lecture 12 1 Last Lecture Trigger Overview This Lecture Java & SQL Source: Lecture notes, Textbook: Chapter 12 JDBC documentation

More information

Setting Up ALERE with Client/Server Data

Setting Up ALERE with Client/Server Data Setting Up ALERE with Client/Server Data TIW Technology, Inc. November 2014 ALERE is a registered trademark of TIW Technology, Inc. The following are registered trademarks or trademarks: FoxPro, SQL Server,

More information

Web Development using PHP (WD_PHP) Duration 1.5 months

Web Development using PHP (WD_PHP) Duration 1.5 months Duration 1.5 months Our program is a practical knowledge oriented program aimed at learning the techniques of web development using PHP, HTML, CSS & JavaScript. It has some unique features which are as

More information

Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11

Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11 Siemens Applied Automation Page 1 Maxum ODBC 3.11 Table of Contents Installing the Polyhedra ODBC driver... 2 Using ODBC with the Maxum Database... 2 Microsoft Access 2000 Example... 2 Access Example (Prior

More information

Creating the Product Catalog Part I (continued)

Creating the Product Catalog Part I (continued) Creating the Product Catalog Part I (continued) Instructor: Wei Ding The lecture notes are written based on the book Beginning ASP.NET 2.0 E-Commerce in C# 2005 From Novice to Profession by Cristian Darie

More information

Visual Basic. murach's TRAINING & REFERENCE

Visual Basic. murach's TRAINING & REFERENCE TRAINING & REFERENCE murach's Visual Basic 2008 Anne Boehm lbm Mike Murach & Associates, Inc. H 1-800-221-5528 (559) 440-9071 Fax: (559) 440-0963 murachbooks@murach.com www.murach.com Contents Introduction

More information

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today. & & 1 & 2 Lecture #7 2008 3 Terminology Structure & & Database server software referred to as Database Management Systems (DBMS) Database schemas describe database structure Data ordered in tables, rows

More information

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring Estimated time to complete this lab: 45 minutes ASP.NET 2.0 s configuration API fills a hole in ASP.NET 1.x by providing an easy-to-use and extensible

More information

SQL Server An Overview

SQL Server An Overview SQL Server An Overview SQL Server Microsoft SQL Server is designed to work effectively in a number of environments: As a two-tier or multi-tier client/server database system As a desktop database system

More information

Embedded SQL programming

Embedded SQL programming Embedded SQL programming http://www-136.ibm.com/developerworks/db2 Table of contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Before

More information

CHAPTER 23: USING ODBC

CHAPTER 23: USING ODBC Chapter 23: Using ODBC CHAPTER 23: USING ODBC Training Objectives In this section, we introduce you to the Microsoft Business Solutions Navision NODBC driver. However, it is recommended that you read and

More information

Using SQL Server Management Studio

Using SQL Server Management Studio Using SQL Server Management Studio Microsoft SQL Server Management Studio 2005 is a graphical tool for database designer or programmer. With SQL Server Management Studio 2005 you can: Create databases

More information

Using Temporary Tables to Improve Performance for SQL Data Services

Using Temporary Tables to Improve Performance for SQL Data Services Using Temporary Tables to Improve Performance for SQL Data Services 2014- Informatica Corporation. No part of this document may be reproduced or transmitted in any form, by any means (electronic, photocopying,

More information

Table of Contents. FleetSoft Installation Guide

Table of Contents. FleetSoft Installation Guide FleetSoft Installation Guide Table of Contents FleetSoft Installation Guide... 1 Minimum System Requirements... 2 Installation Notes... 3 Frequently Asked Questions... 4 Deployment Overview... 6 Automating

More information

Advantage Database Server

Advantage Database Server white paper Advantage Database Server Migrating From Microsoft Access Jet Database Engine Bill Todd, The Database Group, Inc. TABLE OF CONTENTS 1 Introduction 2 Microsoft s Solution 2 Is Advantage Database

More information

Embedded SQL. Unit 5.1. Dr Gordon Russell, Copyright @ Napier University

Embedded SQL. Unit 5.1. Dr Gordon Russell, Copyright @ Napier University Embedded SQL Unit 5.1 Unit 5.1 - Embedde SQL - V2.0 1 Interactive SQL So far in the module we have considered only the SQL queries which you can type in at the SQL prompt. We refer to this as interactive

More information

FileMaker 12. ODBC and JDBC Guide

FileMaker 12. ODBC and JDBC Guide FileMaker 12 ODBC and JDBC Guide 2004 2012 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker and Bento are trademarks of FileMaker, Inc.

More information

Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences. Mike Dempsey

Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences. Mike Dempsey Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences by Mike Dempsey Overview SQL Assistant 13.0 is an entirely new application that has been re-designed from the ground up. It has been

More information

Database migration using Wizard, Studio and Commander. Based on migration from Oracle to PostgreSQL (Greenplum)

Database migration using Wizard, Studio and Commander. Based on migration from Oracle to PostgreSQL (Greenplum) Step by step guide. Database migration using Wizard, Studio and Commander. Based on migration from Oracle to PostgreSQL (Greenplum) Version 1.0 Copyright 1999-2012 Ispirer Systems Ltd. Ispirer and SQLWays

More information

SQL Server Database Coding Standards and Guidelines

SQL Server Database Coding Standards and Guidelines SQL Server Database Coding Standards and Guidelines http://www.sqlauthority.com Naming Tables: Stored Procs: Triggers: Indexes: Primary Keys: Foreign Keys: Defaults: Columns: General Rules: Rules: Pascal

More information

More SQL: Assertions, Views, and Programming Techniques

More SQL: Assertions, Views, and Programming Techniques 9 More SQL: Assertions, Views, and Programming Techniques In the previous chapter, we described several aspects of the SQL language, the standard for relational databases. We described the SQL statements

More information

Connect to MySQL or Microsoft SQL Server using R

Connect to MySQL or Microsoft SQL Server using R Connect to MySQL or Microsoft SQL Server using R 1 Introduction Connecting to a MySQL database or Microsoft SQL Server from the R environment can be extremely useful. It allows a research direct access

More information

Oracle SQL. Course Summary. Duration. Objectives

Oracle SQL. Course Summary. Duration. Objectives Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data

More information

Database Programming with PL/SQL: Learning Objectives

Database Programming with PL/SQL: Learning Objectives Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs

More information

Microsoft SQL Server Installation Guide

Microsoft SQL Server Installation Guide Microsoft SQL Server Installation Guide Version 3.0 For SQL Server 2014 Developer & 2012 Express October 2014 Copyright 2010 2014 Robert Schudy, Warren Mansur and Jack Polnar Permission granted for any

More information

RTI Database Integration Service. Getting Started Guide

RTI Database Integration Service. Getting Started Guide RTI Database Integration Service Getting Started Guide Version 5.2.0 2015 Real-Time Innovations, Inc. All rights reserved. Printed in U.S.A. First printing. June 2015. Trademarks Real-Time Innovations,

More information

Knocker main application User manual

Knocker main application User manual Knocker main application User manual Author: Jaroslav Tykal Application: Knocker.exe Document Main application Page 1/18 U Content: 1 START APPLICATION... 3 1.1 CONNECTION TO DATABASE... 3 1.2 MODULE DEFINITION...

More information

Hands-On Lab. Client Workflow. Lab version: 1.0.0 Last updated: 2/23/2011

Hands-On Lab. Client Workflow. Lab version: 1.0.0 Last updated: 2/23/2011 Hands-On Lab Client Workflow Lab version: 1.0.0 Last updated: 2/23/2011 CONTENTS OVERVIEW... 3 EXERCISE 1: DEFINING A PROCESS IN VISIO 2010... 4 Task 1 Define the Timesheet Approval process... 4 Task 2

More information

GoDaddy (CentriqHosting): Data driven Web Application Deployment

GoDaddy (CentriqHosting): Data driven Web Application Deployment GoDaddy (CentriqHosting): Data driven Web Application Deployment Process Summary There a several steps to deploying an ASP.NET website that includes databases (for membership and/or for site content and

More information

Introduction to Visual Basic and Visual C++ Database Foundation. Types of Databases. Data Access Application Models. Introduction to Database System

Introduction to Visual Basic and Visual C++ Database Foundation. Types of Databases. Data Access Application Models. Introduction to Database System Introduction to Visual Basic and Visual C++ Database Foundation Lesson 8 Introduction to Database System I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Data Access Application Models Types of

More information

4 Simple Database Features

4 Simple Database Features 4 Simple Database Features Now we come to the largest use of iseries Navigator for programmers the Databases function. IBM is no longer developing DDS (Data Description Specifications) for database definition,

More information