public DataSet GetData() { SqlConnection con; SqlDataAdapter da; DataSet ds; string cs, sql; cs = ConfigurationSettings.AppSettings["ConnectionString"]; sql = "SELECT * FROM authors"; try { con = new SqlConnection(cs); da = new SqlDataAdapter(sql, con); ds = new DataSet(); da.Fill(ds); return ds; } catch (SqlException ex) { InworxException ex2; ex2 = new InworxException("Error en DataLayer.GetData", ex, true); throw ex2; } finally { } }
// Devuelve un dataset con los datos de la base public DataSet GetData() { SqlConnection con; SqlDataAdapter da; DataSet ds; string cs, sql; // String de conexion a la base de datos //cs = "Data Source=.; Initial catalog=pubs; User ID=sa; Password=inworx"; cs = ConfigurationSettings.AppSettings["ConnectionString"]; // SQL a ejecutar sql = "SELECT * FROM authors"; try { con = new SqlConnection(cs); da = new SqlDataAdapter(sql, con); ds = new DataSet(); da.Fill(ds); //Aca se abre la conexion implicitamente return ds; } catch (SqlException ex) { InworxException ie = new InworxException("Error en DataLayer - " + ex.Message + " - " + ex.StackTrace, ex, true); throw ie; return null; } finally { } }
public void Update(string Id, string LastName, string FirstName) { SqlConnection con = null; SqlCommand cmd; string cs, sql; cs = ConfigurationSettings.AppSettings["ConnectionString"]; sql = "UPDATE authors SET au_lname='{1}', au_fname='{2}' WHERE au_id='{0}'"; sql = string.Format(sql, Id, FirstName, LastName); try { con = new SqlConnection(cs); cmd = new SqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); } catch (SqlException ex) { InworxException ex2; ex2 = new InworxException("Error en DataLayer.AuthorDALC.Update", ex, true); throw ex2; } finally { con.Close(); } }
public void GetData(string Id, out string LastName, out string FirstName) { SqlConnection con; SqlDataAdapter da; DataSet ds; string cs, sql; cs = ConfigurationSettings.AppSettings["ConnectionString"]; sql = "SELECT * FROM authors WHERE au_id='{0}'"; sql = string.Format(sql, Id); try { con = new SqlConnection(cs); da = new SqlDataAdapter(sql, con); ds = new DataSet(); da.Fill(ds); FirstName = ds.Tables[0].Rows[0]["au_fname"].ToString(); LastName = ds.Tables[0].Rows[0]["au_lname"].ToString(); } catch (SqlException ex) { InworxException ex2; ex2 = new InworxException("Error en DataLayer.GetData", ex, true); throw ex2; } finally { } }
public DataSet GetData() { try { DataClass data = new DataClass(); return data.GetData(); } catch(InworxException e) { InworxException ex = new InworxException("Error en Business Layer - " + e.Message + " - " + e.StackTrace, e); throw ex; } }
public DataSet GetData() { DataClass data; try { data = new DataClass(); return data.GetData(); } catch(InworxException ex) { InworxException ex2; ex2 = new InworxException("Error en BusinessLayer.GetData", ex); return null; } }
public DataSet GetData() { SqlConnection con; SqlDataAdapter da; DataSet ds; string cs; //Data Source=. : mi maquina //Conexion fija //cs = "Data Source=.; Initial Catalog=pubs; User ID=sa; Password=inworx"; //Conexion por settings cs = ConfigurationSettings.AppSettings["ConnectionString"]; //XmlDocument doc = new XmlDocument(); try { //Conexión con = new SqlConnection(cs); //Adapter da = new SqlDataAdapter("select * from authors", con); //Dataset & Fill //Fill hace open, tira el comando, llena el dataset y luego hace close ds = new DataSet(); da.Fill(ds); return ds; } catch (SqlException ex) { InworxException ex2; ex2 = new InworxException("Error en GetData", ex, true); throw ex2; } finally { } }