Successfully reported this slideshow.

Proveedor manuel

303 views

Published on

proveedor

Published in: Education
  • Be the first to comment

  • Be the first to like this

Proveedor manuel

  1. 1. Instituto Tecnológico Superior de CoatzacoalcosIngeniería en Informática Modalidad AbiertoALUMNO:Manuel Santiago José AugustoSemestre: 6° Grupo: ANombre del Docente: ISC Rosario de Alba Domínguez RodríguezFecha de entrega: 3 de junio de 2013DESARROLLO DE APLICACIONES WEB.Unidad 2: Entorno de programaciónActividad 1: Componentes de un proveedor de datos.NET
  2. 2. System.Data.OracleClient• OracleCommand• OracleConnection• OracleDataReader• OracleDatSetObjetos principalesProveedor SQLObjetos principalesADO.NETProveedor OLEDBProveedor ODBCEspacio de nombresProveedor OracleEspacio de nombresSystem.Data.OleDb System.Data.SqlClient• SqlConnection• SqlCommand• SqlDataAdapter• DataSet• DataTables• OleDbCommand• OleDbConnection• OleDbDatadapter• OleDbDataReaderObjetos principalesEspacio de nombresSystem.Data.OdbcObjetos principales• OdbcCommand• OdbcConnection• OdbcDataAdapter• OdbcDataReaderEspacio de nombresDataSetMapa conceptual. Componentes de un proveedor de datos .NETProveedoresComponentes
  3. 3. Código ejemplo en C#Conectando con una BD Oracle utilizando OdbcusingMicrosoft.Data.Odbc;OdbcConnection myConn = new OdbcConnection("DSN=MYDNS;UID=MYUID;PWD=mypass;");myConn.Open();String mySql = "select 1 from dual";OdbcCommand myCmd = new OdbcCommand(mySql, myCon);OdbcDataReader myReader = myCmd.ExecuteReader();while (myReader.Read()) {Console.WriteLine(myReader.GetString(0));}Conectando con una BD en SQL ServerusingSystem.Data.OleDb;usingSystem.Data.Sql;usingSystem.Data.SqlClient;System.Data.SqlClient.SqlConnection con;con = new System.Data.SqlClient.SqlConnection();con.ConnectionString = “con.ConnectionString = "DataSource=.SQLEXPRESS;AttachDbFilename=H:NEGOCIO.mdf;Integrated Security=True;ConnectTimeout=30;User Instance=True";try { con.Open();MessageBox.Show("La conexión a la base de datos se estableció exitosamente"); }catch (Exception) { MessageBox.Show("No se pudo establecer la conexión a la base dedatos. El sistema se cerrará"); this.Close();}
  4. 4. Conectando con una BD utilizando Oledbusing System;usingSystem.Data;usingSystem.Data.OleDb;class Program{static void Main(){stringconnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ "c:DataNorthwind.mdb;User Id=admin;Password=;";// Provide the query string with a parameter placeholder.stringqueryString ="SELECT ProductID, UnitPrice, ProductName from products "+ "WHERE UnitPrice> ? "+ "ORDER BY UnitPrice DESC;";intparamValue = 5;using (OleDbConnection connection =newOleDbConnection(connectionString)){// Create the Command and Parameter objects.OleDbCommand command = new OleDbCommand(queryString, connection);command.Parameters.AddWithValue("@pricePoint", paramValue);// Open the connection in a try/catch block.
  5. 5. // Create and execute the DataReader, writing the result// set to the console window.try{connection.Open();OleDbDataReader reader = command.ExecuteReader();while (reader.Read()){Console.WriteLine("t{0}t{1}t{2}",reader[0], reader[1], reader[2]);}reader.Close();}catch (Exception ex){Console.WriteLine(ex.Message);}Console.ReadLine();}}
  6. 6. Conectando con una bd utilizando Odbcusing System;usingSystem.Data;usingSystem.Data.Odbc;class Program{ static void Main(){ stringconnectionString = "Driver={Microsoft Access Driver (*.mdb)};"+ "Dbq=c:DataNorthwind.mdb;Uid=Admin;Pwd=;";stringqueryString ="SELECT ProductID, UnitPrice, ProductName from products "+ "WHERE UnitPrice> ? "+ "ORDER BY UnitPrice DESC;";intparamValue = 5;using (OdbcConnection connection =newOdbcConnection(connectionString)){OdbcCommand command = new OdbcCommand(queryString, connection);command.Parameters.AddWithValue("@pricePoint", paramValue);intparamValue = 5;using (OdbcConnection connection =newOdbcConnection(connectionString)){// Create the Command and Parameter objects.OdbcCommand command = new OdbcCommand(queryString, connection);
  7. 7. command.Parameters.AddWithValue("@pricePoint", paramValue);try{ connection.Open();OdbcDataReader reader = command.ExecuteReader();while (reader.Read()){ Console.WriteLine("t{0}t{1}t{2}",reader[0], reader[1], reader[2]);}reader.Close();}catch (Exception ex) { Console.WriteLine(ex.Message);}Console.ReadLine(); }}
  8. 8. Referencias electrónicas http://msdn.microsoft.com/es-es/library/ms228366(v=vs.80).aspx http://msdn.microsoft.com/es-es/library/ms254507.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 http://msdn.microsoft.com/es-es/library/aa719763(v=vs.71).aspx http://www.slideshare.net/jman861/savedfiles?s_title=conexin-c-sql-server&user_login=LUZARIZPE http://www.slideshare.net/mdurantorres/conexin-a-sql-server-con-c http://wiki.elhacker.net/programacion/dotnet/generalidades/bibliotecas-principales

×