// GET: /Mobiles/Edit/5 public ActionResult Edit(int SLNo) { Mobiles mobile = new Mobiles(); DataTable mobileTable = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); // Prone to SQL enjection string query = "SELECT * FROM Mobiles Where SLNo = ?"; IfxDataAdapter ifx = new IfxDataAdapter(query, Con); ifx.SelectCommand.Parameters.Add("SLNo", IfxType.Serial).Value = SLNo; ifx.Fill(mobileTable); Con.Close(); } if (mobileTable.Rows.Count == 1) { mobile.SLNo = Convert.ToInt32(mobileTable.Rows[0][0].ToString()); mobile.MobileName = mobileTable.Rows[0][1].ToString(); mobile.Price = Convert.ToDecimal(mobileTable.Rows[0][2].ToString()); mobile.Quantity = Convert.ToInt32(mobileTable.Rows[0][3].ToString()); mobile.Description = mobileTable.Rows[0][4].ToString(); mobile.PicURL = mobileTable.Rows[0][5].ToString(); mobile.Model = mobileTable.Rows[0][6].ToString(); mobile.Features = mobileTable.Rows[0][7].ToString(); mobile.Color = mobileTable.Rows[0][8].ToString(); mobile.SimType = mobileTable.Rows[0][9].ToString(); return(View(mobile)); } else { return(RedirectToAction("Index")); } }
public ActionResult EachProductDetails(Mobiles mobile) { DataTable mobileTable = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); // Prone to SQL enjection string query = "SELECT * FROM Mobiles Where SLNo = ?"; IfxDataAdapter ifx = new IfxDataAdapter(query, Con); ifx.SelectCommand.Parameters.Add("SLNo", IfxType.Serial).Value = mobile.SLNo; ifx.Fill(mobileTable); Con.Close(); } Mobiles mobileDetail = new Mobiles(); for (int i = 0; i < mobileTable.Rows.Count; i++) { mobileDetail.SLNo = Convert.ToInt32(mobileTable.Rows[0][0].ToString()); mobileDetail.MobileName = mobileTable.Rows[0][1].ToString(); mobileDetail.Price = Convert.ToDecimal(mobileTable.Rows[0][2].ToString()); mobileDetail.Quantity = Convert.ToInt32(mobileTable.Rows[0][3].ToString()); mobileDetail.Description = mobileTable.Rows[0][4].ToString(); mobileDetail.PicURL = mobileTable.Rows[0][5].ToString(); mobileDetail.Model = mobileTable.Rows[0][6].ToString(); mobileDetail.Features = mobileTable.Rows[0][7].ToString(); mobileDetail.Color = mobileTable.Rows[0][8].ToString(); mobileDetail.SimType = mobileTable.Rows[0][9].ToString(); } return(View(mobileDetail)); }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM orderdetails", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table orderdetails (orderid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, PurchaseDate varchar(50), Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM orderdetails", Con); ifx.Fill(table); } finally { Con.Close(); } return(View(table)); } }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Mobiles", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table Mobiles (SLNo serial PRIMARY KEY, MobileName nvarchar(100) NULL, Price decimal(18, 2)," + " Quantity int NULL, Description nvarchar(250) NULL, PicURL nvarchar(250) NULL," + " Model nvarchar(50) NULL, Features nvarchar(200) NULL, Color nvarchar(20) NULL, SimType nvarchar(10) NULL, ImageFile Blob)"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Mobiles", Con); ifx.Fill(table); } finally { Con.Close(); } } return(View(table)); }
public ActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Product", Con); ifx.Fill(table); } catch (Exception ex) { string createProductTable = "Create table Product (productid serial PRIMARY KEY, productname varchar(50), price decimal(18,2), count int)"; IfxCommand cmd = new IfxCommand(createProductTable, Con); cmd.ExecuteNonQuery(); string createOrderTable = "Create table orderdetails (orderid serial PRIMARY KEY, productid int, productname varchar(50), price decimal(18,2), count int, totalamount decimal(18,2))"; IfxCommand cmd1 = new IfxCommand(createOrderTable, Con); cmd1.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Product", Con); ifx.Fill(table); } } return(View(table)); }
// GET: /Product/Edit/5 public ActionResult Edit(int id) { ProductModel productModel = new ProductModel(); DataTable tblProd = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); // Prone to SQL enjection string query = "SELECT * FROM Product Where productid = ?"; IfxDataAdapter ifx = new IfxDataAdapter(query, Con); ifx.SelectCommand.Parameters.Add("productid", IfxType.Serial).Value = id; ifx.Fill(tblProd); } if (tblProd.Rows.Count == 1) { productModel.ProductID = Convert.ToInt32(tblProd.Rows[0][0].ToString()); productModel.ProductName = tblProd.Rows[0][1].ToString(); productModel.Price = Convert.ToDecimal(tblProd.Rows[0][2].ToString()); productModel.Count = Convert.ToInt32(tblProd.Rows[0][3].ToString()); return(View(productModel)); } else { return(RedirectToAction("Index")); } }
public static DataTable RunSPReturnDataTable(string spName, Paras paras, IfxConnection conn) { try { IfxCommand salesCMD = new IfxCommand(spName, conn); salesCMD.CommandType = CommandType.StoredProcedure; /// 加上他们的餐数 foreach (Para para in paras) { IfxParameter myParm = salesCMD.Parameters.Add(para.ParaName, para.DAType); myParm.Value = para.val; } //selectCMD.CommandTimeout =60; IfxDataAdapter sda = new IfxDataAdapter(salesCMD); if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } DataTable dt = new DataTable(); sda.Fill(dt); sda.Dispose(); return(dt); } catch (System.Exception ex) { throw ex; } }
public DataTable SelactAll(string query) { da = new IfxDataAdapter(query, EcomDetailsDAL.connect()); DataTable dt = new DataTable(); da.Fill(dt); return(dt); }
private void button1_Click(object sender, RoutedEventArgs e) { if (textBoxUserName.Text.Length == 0) { errormessage.Text = "Enter a user name."; textBoxUserName.Focus(); } else { string username = textBoxUserName.Text; string password = passwordBox1.Password; DataSet dataSet = new DataSet(); string selectSQL = "Select * from user where username='******' and password='******'"; con = new IfxConnection(cs); con.Open(); try { IfxCommand cmd = new IfxCommand(selectSQL, con); cmd.CommandType = CommandType.Text; IfxDataAdapter adapter = new IfxDataAdapter(); adapter.SelectCommand = cmd; adapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count > 0) { string name = dataSet.Tables[0].Rows[0]["FirstName"].ToString() + " " + dataSet.Tables[0].Rows[0]["LastName"].ToString(); string userType = dataSet.Tables[0].Rows[0]["UserType"].ToString(); if (userType == "Admin") { AllUserDetails allUser = new AllUserDetails(name); allUser.Show(); } else { UserProfile userProfile = new UserProfile(); userProfile.TextBlockName.Text = name; userProfile.Show(); } Close(); } else { errormessage.Text = "Sorry! Please enter correct username/password."; } } catch (Exception ex) { errormessage.Text = "You need to register first before login."; } finally { con.Close(); } } }
private void tabControl1_Selected(object sender, TabControlEventArgs e) { // Move the input focus to the query builder. // This will fire Leave event in the text box and update the query builder // with modified query text. queryBuilder1.Focus(); Application.DoEvents(); // Try to execute the query using current database connection: if (e.TabPage == tabPageData) { dataGridView1.DataSource = null; if (queryBuilder1.MetadataProvider != null && queryBuilder1.MetadataProvider.Connected) { IfxCommand command = (IfxCommand)queryBuilder1.MetadataProvider.Connection.CreateCommand(); command.CommandText = queryBuilder1.SQL; // handle the query parameters if (queryBuilder1.Parameters.Count > 0) { for (int i = 0; i < queryBuilder1.Parameters.Count; i++) { if (!command.Parameters.Contains(queryBuilder1.Parameters[i].FullName)) { IfxParameter parameter = new IfxParameter(); parameter.ParameterName = queryBuilder1.Parameters[i].FullName; parameter.DbType = queryBuilder1.Parameters[i].DataType; command.Parameters.Add(parameter); } } using (QueryParametersForm qpf = new QueryParametersForm(command)) { qpf.ShowDialog(); } } IfxDataAdapter adapter = new IfxDataAdapter(command); DataSet dataset = new DataSet(); try { adapter.Fill(dataset, "QueryResult"); dataGridView1.DataSource = dataset.Tables["QueryResult"]; } catch (Exception ex) { MessageBox.Show(ex.Message, "SQL query error"); } } } }
public static DataTable ExecuteQuery(IfxCommand command, IfxConnection conn, IfxTransaction trans) { DataTable result = new DataTable(); command.Connection = conn; command.Transaction = trans; IBM.Data.Informix.IfxDataAdapter datoIFX = default(IBM.Data.Informix.IfxDataAdapter); datoIFX = new IfxDataAdapter(); datoIFX.SelectCommand = command; datoIFX.Fill(result); datoIFX.Dispose(); return(result); }
public DbDataAdapter CreateAdapter() { try { DbDataAdapter dtAdapter = null; dtAdapter = new IfxDataAdapter(); return(dtAdapter); } catch (Exception) { throw; } }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM cart", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table cart (cartid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM cart", Con); ifx.Fill(table); } finally { Con.Close(); } } List <Cart> cartList = new List <Cart>(); for (int i = 0; i < table.Rows.Count; i++) { Cart cart = new Cart(); cart.CartID = Convert.ToInt32(table.Rows[i]["CartID"]); cart.SLNo = Convert.ToInt32(table.Rows[i]["SLNo"]); cart.MobileName = table.Rows[i]["MobileName"].ToString(); cart.Description = table.Rows[i]["Description"].ToString(); cart.PicURL = table.Rows[i]["PicURL"].ToString(); cart.Model = table.Rows[i]["Model"].ToString(); cart.Features = table.Rows[i]["Features"].ToString(); cart.Color = table.Rows[i]["Color"].ToString(); cart.SimType = table.Rows[i]["SimType"].ToString(); cart.Price = Convert.ToDecimal(table.Rows[i]["Price"]); cart.Quantity = Convert.ToInt32(table.Rows[i]["Quantity"]); cart.TotalAmount = Convert.ToDecimal(table.Rows[i]["TotalAmount"]); cartList.Add(cart); } return(View(cartList)); }
//EJECUTA UN QUERY public static DataTable ExecuteQuery(IfxCommand command, string chain) { DataTable result = new DataTable(); IfxConnection conexionIFX = new IfxConnection(); IBM.Data.Informix.IfxDataAdapter datoIFX = default(IBM.Data.Informix.IfxDataAdapter); conexionIFX = new IfxConnection(chain); conexionIFX.Open(); command.Connection = conexionIFX; datoIFX = new IfxDataAdapter(); datoIFX.SelectCommand = command; datoIFX.Fill(result); datoIFX.Dispose(); conexionIFX.Close(); return(result); }
private void DisplayDataForQuery() { dataGridView1.DataSource = null; if (queryBuilder.MetadataProvider != null && queryBuilder.MetadataProvider.Connected) { if (queryBuilder.MetadataProvider is InformixMetadataProvider) { IfxCommand command = (IfxCommand)queryBuilder.MetadataProvider.Connection.CreateCommand(); command.CommandText = queryBuilder.SQL; // handle the query parameters if (queryBuilder.Parameters.Count > 0) { for (int i = 0; i < queryBuilder.Parameters.Count; i++) { if (!command.Parameters.Contains(queryBuilder.Parameters[i].FullName)) { IfxParameter parameter = new IfxParameter(); parameter.ParameterName = queryBuilder.Parameters[i].FullName; parameter.DbType = queryBuilder.Parameters[i].DataType; command.Parameters.Add(parameter); } } using (QueryParametersForm qpf = new QueryParametersForm(command)) { qpf.ShowDialog(); } } IfxDataAdapter adapter = new IfxDataAdapter(command); DataSet dataset = new DataSet(); try { adapter.Fill(dataset, "QueryResult"); dataGridView1.DataSource = dataset.Tables["QueryResult"]; } catch (Exception ex) { MessageBox.Show(ex.Message, "SQL query error"); } } //end informix } //end check if connected } //end method
private void searchSLNoInCartTable(IfxConnection con, int sLNo, Mobiles mobile, int selectedQuantity) { DataTable cartTable = new DataTable(); string cartQuery = "SELECT * FROM Cart Where SLNo = ?"; IfxDataAdapter ifxCart = new IfxDataAdapter(cartQuery, con); ifxCart.SelectCommand.Parameters.Add("SLNo", IfxType.Serial).Value = sLNo; ifxCart.Fill(cartTable); if (cartTable.Rows.Count == 1) { int SavedQuantity = Convert.ToInt32(cartTable.Rows[0][10].ToString()); decimal ItemPrice = Convert.ToDecimal(cartTable.Rows[0][9].ToString()); updateToCart(con, mobile, selectedQuantity, SavedQuantity, ItemPrice); } else { insertToCart(con, mobile, selectedQuantity); } }
public ActionResult AddToCart(Mobiles mobileDetails) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); int selectedQuantity = mobileDetails.Quantity; Mobiles mobile = new Mobiles(); DataTable mobileTable = new DataTable(); string query = "SELECT * FROM Mobiles Where SLNo = ?"; IfxDataAdapter ifx = new IfxDataAdapter(query, Con); ifx.SelectCommand.Parameters.Add("SLNo", IfxType.Serial).Value = mobileDetails.SLNo; ifx.Fill(mobileTable); if (mobileTable.Rows.Count == 1) { mobile.SLNo = Convert.ToInt32(mobileTable.Rows[0][0].ToString()); mobile.MobileName = mobileTable.Rows[0][1].ToString(); mobile.Price = Convert.ToDecimal(mobileTable.Rows[0][2].ToString()); mobile.Quantity = Convert.ToInt32(mobileTable.Rows[0][3].ToString()); mobile.Description = mobileTable.Rows[0][4].ToString(); mobile.PicURL = mobileTable.Rows[0][5].ToString(); mobile.Model = mobileTable.Rows[0][6].ToString(); mobile.Features = mobileTable.Rows[0][7].ToString(); mobile.Color = mobileTable.Rows[0][8].ToString(); mobile.SimType = mobileTable.Rows[0][9].ToString(); } else { Con.Close(); mobile.ErrorMessage = "Error : Unable to get mobile details"; } if (selectedQuantity > mobile.Quantity) { Con.Close(); mobile.ErrorMessage = "Cannot purchase " + selectedQuantity + " quantities, available quantities are : " + mobile.Quantity; } else { try { searchSLNoInCartTable(Con, mobileDetails.SLNo, mobile, selectedQuantity); } catch (Exception ex) { string createCartTable = "Create table cart (cartid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd2 = new IfxCommand(createCartTable, Con); cmd2.ExecuteNonQuery(); searchSLNoInCartTable(Con, mobileDetails.SLNo, mobile, selectedQuantity); } finally { Con.Close(); mobile.ErrorMessage = "Added to cart successfully"; } } // return View(mobile); return(RedirectToAction("Index", "Home")); } }
public ActionResult CreateOrder() { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); DataTable cartTable = new DataTable(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM cart", Con); ifx.Fill(cartTable); Con.Close(); List <MyOrders> orderList = new List <MyOrders>(); for (int i = 0; i < cartTable.Rows.Count; i++) { MyOrders order = new MyOrders(); order.PurchaseDate = DateTime.UtcNow.ToString(); order.SLNo = Convert.ToInt32(cartTable.Rows[i]["SLNo"]); order.MobileName = cartTable.Rows[i]["MobileName"].ToString(); order.Description = cartTable.Rows[i]["Description"].ToString(); order.PicURL = cartTable.Rows[i]["PicURL"].ToString(); order.Model = cartTable.Rows[i]["Model"].ToString(); order.Features = cartTable.Rows[i]["Features"].ToString(); order.Color = cartTable.Rows[i]["Color"].ToString(); order.SimType = cartTable.Rows[i]["SimType"].ToString(); order.Price = Convert.ToDecimal(cartTable.Rows[i]["Price"]); order.Quantity = Convert.ToInt32(cartTable.Rows[i]["Quantity"]); order.TotalAmount = Convert.ToDecimal(cartTable.Rows[i]["TotalAmount"]); orderList.Add(order); } foreach (MyOrders order in orderList) { Con.Open(); int SLNo = order.SLNo; int availableQuantity = 0; string selectMobileDetails = "select Quantity from mobiles where SLNo = ?"; IfxCommand cmd = new IfxCommand(selectMobileDetails, Con); cmd.Parameters.Add("slno", IfxType.Serial).Value = SLNo; try { IfxDataReader rows = cmd.ExecuteReader(); while (rows.Read()) { availableQuantity = Convert.ToInt32(rows[0]); } rows.Close(); } catch (IfxException ex) { Con.Close(); order.ErrorMessage = "Error : " + ex.Message; } if (order.Quantity > availableQuantity) { Con.Close(); order.ErrorMessage = "Cannot purchase " + order.Quantity + " quantities, available quantities are : " + availableQuantity; } else { int newMobileQuantity = availableQuantity - order.Quantity; string updateMobileQuantity = "UPDATE Mobiles SET Quantity = ? Where SLNo = ?"; IfxCommand cmd1 = new IfxCommand(updateMobileQuantity, Con); cmd1.Parameters.Add("quantity", IfxType.Int).Value = newMobileQuantity; cmd1.Parameters.Add("slno", IfxType.Serial).Value = SLNo; cmd1.ExecuteNonQuery(); try { insertNewOrder(Con, order); } catch (Exception ex) { string createOrderTable = "Create table orderdetails (orderid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, PurchaseDate varchar(50), Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd2 = new IfxCommand(createOrderTable, Con); cmd2.ExecuteNonQuery(); insertNewOrder(Con, order); } finally { Con.Close(); order.ErrorMessage = "Purchase successful"; } } Con.Close(); } Con.Open(); string delQuery = "DELETE FROM Cart"; IfxCommand delCmd = new IfxCommand(delQuery, Con); delCmd.ExecuteNonQuery(); Con.Close(); } return(RedirectToAction("Index")); }
public List<FACSHeader> GetFacility(string tel_num) { try { List<FACSHeader> facilities = new List<FACSHeader>(); using (IfxConnection ifxcon = new IfxConnection(INFORMIXDB)) { DataSet ds = new DataSet(); // Initialize Command and DataAdapter IfxCommand cmd; IfxDataAdapter da; // Open Connection and call stored procedure. ifxcon.Open(); cmd = new IfxCommand("ht_one_facs_dash", ifxcon); cmd.CommandType = CommandType.StoredProcedure; // Stored procedure parameters. cmd.Parameters.Add("p_tel_no ", IfxType.VarChar, 256).Value = tel_num; // Fill Dataset using DataAdapter da = new IfxDataAdapter(cmd); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { FACSHeader fac = new FACSHeader(); fac.Tel_Num = dr[0].ToString().Trim(); fac.Status = dr[1].ToString().Trim(); fac.Remarks = dr[2].ToString().Trim(); fac.Cable_Pair = dr[3].ToString().Trim(); fac.Port = dr[4].ToString().Trim(); facilities.Add(fac); } ifxcon.Close(); } return facilities; } catch (Exception) { throw; } }
public List<FACSDetail> GetFacilityDetail(string tel_num) { try { List<FACSDetail> facDetails = new List<FACSDetail>(); using (IfxConnection ifxcon = new IfxConnection(INFORMIXDB)) { DataSet ds = new DataSet(); // Initialize Command and DataAdapter IfxCommand cmd; IfxDataAdapter da; // Open Connection and call stored procedure. ifxcon.Open(); cmd = new IfxCommand("ht_one_facs", ifxcon); cmd.CommandType = CommandType.StoredProcedure; // Stored procedure parameters. cmd.Parameters.Add("p_tel_no ", IfxType.VarChar, 256).Value = tel_num; // Fill Dataset using DataAdapter da = new IfxDataAdapter(cmd); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { FACSDetail facD = new FACSDetail(); facD.Tel_Num = dr[0].ToString().Trim(); facD.Status = dr[1].ToString().Trim(); facD.Native_ACO = dr[2].ToString().Trim(); facD.Current_ACO = dr[3].ToString().Trim(); facD.Switch_Type = dr[4].ToString().Trim(); facD.CLLI = dr[5].ToString().Trim(); facD.Terminal = dr[6].ToString().Trim(); facD.Port = dr[7].ToString().Trim(); facD.Facilities = dr[8].ToString().Trim(); facD.XBox = dr[9].ToString().Trim(); facD.InterIsland_PIC = dr[11].ToString().Trim(); facD.InterNational_PIC = dr[10].ToString().Trim(); facD.Address = dr[12].ToString().Trim(); facD.Remarks = dr[13].ToString().Trim(); facD.Service_Type = dr[14].ToString().Trim(); facD.MITS = dr[15].ToString().Trim(); facD.SR_TN = dr[16].ToString().Trim(); facDetails.Add(facD); } ifxcon.Close(); } return facDetails; } catch (Exception) { throw; } }
public Pic GetPic(string id, string tn, int index) { Pic selectedPic = new Pic(); try { List<Pic> pics = new List<Pic>(); using (OracleConnection con = new OracleConnection(KENANDB)) { DataSet ds = new DataSet(); // Initialize Command and DataAdapter. OracleCommand cmd; OracleDataAdapter da; // Open Connection and call stored procedure. con.Open(); cmd = new OracleCommand("ARBOR.HT_ONE_PKG.GET_PIC", con); cmd.CommandType = CommandType.StoredProcedure; // Stored procedure parameters. cmd.Parameters.Add("iAccountNo", OracleType.VarChar, 20).Value = id; cmd.Parameters["iAccountNo"].Direction = ParameterDirection.Input; cmd.Parameters.Add("oPicInfo", OracleType.Cursor).Direction = ParameterDirection.Output; // Fill Dataset using DataAdapter da = new OracleDataAdapter(cmd); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { Pic pic = new Pic(); pic.subscr_no = dr[0].ToString().Trim(); pic.tn = dr[1].ToString().Trim(); pic.formattedTn = dr[2].ToString().Trim(); pic.mainland = dr[3].ToString().Trim(); pic.interisland = dr[4].ToString().Trim(); pic.international = dr[5].ToString().Trim(); pics.Add(pic); } selectedPic = pics.Where(a => a.tn == tn).Single<Pic>(); selectedPic.index = index; con.Close(); } } catch (Exception) { throw; } try { List<NBPic> facDetails = new List<NBPic>(); using (IfxConnection ifxcon = new IfxConnection(INFORMIXDB)) { DataSet ds = new DataSet(); // Initialize Command and DataAdapter IfxCommand cmd; IfxDataAdapter da; // Open Connection and call stored procedure. ifxcon.Open(); cmd = new IfxCommand("ht_one_facs", ifxcon); cmd.CommandType = CommandType.StoredProcedure; // Stored procedure parameters. cmd.Parameters.Add("p_tel_no ", IfxType.VarChar, 256).Value = tn; // Fill Dataset using DataAdapter da = new IfxDataAdapter(cmd); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { NBPic facD = new NBPic(); facD.InterIsland_PIC = dr[11].ToString().Trim(); facD.InterNational_PIC = dr[10].ToString().Trim(); facDetails.Add(facD); } ifxcon.Close(); } selectedPic.NBPics = facDetails; } catch (Exception) { throw; } return selectedPic; }
public override void RunCommand(object sender) { var engine = (Core.Automation.Engine.AutomationEngineInstance)sender; string query = "select * from alumno"; string connectionString; connectionString = "Database = mi_prueba_base_datos; Host = 127.0.0.1; Server = dr_informix1210_4; Service = 10987; UID = informix; Password = A3.cY2zd8*CBjTFM;";//Protocol = onsoctcp; string ConnectionString = "Host=" + "127.0.0.1" + "; " + "Service=" + "10987" + "; " + "Server=" + "dr_informix1210_4" + "; " + "Database=" + "mi_prueba_base_datos" + "; " + "User Id=" + "informix" + "; " + "Password="******"A3.cY2zd8*CBjTFM" + "; "; //Can add other DB parameters here like DELIMIDENT, DB_LOCALE etc //Full list in Client SDK's .Net Provider Reference Guide p 3:13 IfxConnection conn = new IfxConnection(); conn.ConnectionString = ConnectionString; try { conn.Open(); Console.WriteLine("Made connection!"); Console.ReadLine(); } catch (IfxException ex) { Console.WriteLine("Problem with connection attempt: " + ex.Message); } IfxConnection connection = null; try { connection.Open(); } catch (IfxException ex) { } //Create Command IfxCommand cmd = new IfxCommand(query, connection); //Create a data reader and Execute the command DataTable dataTable = new DataTable(); IfxDataAdapter adapter = new IfxDataAdapter(cmd); adapter.Fill(dataTable); dataTable.TableName = v_DatasetName; engine.DataTables.Add(dataTable); engine.AddVariable(v_DatasetName, dataTable); try { connection.Close(); } catch (IfxException ex) { } }