here is my code, constring is kept private global <pre lang="c#">public void retrieveFromDB(int proID) { string selectcmd = "SELECT * FROM [store].[dbo].[tblproduct] WHERE [proID]='" + proID + "'"; SqlConnection con = new SqlConnection(constring); con.Open(); SqlCommand select = new SqlCommand(selectcmd, con); SqlDataAdapter sda = new SqlDataAdapter(select); sda.Fill(table); con.Close(); }
productTbl protbl = null; protbl.retrieveFromDB(1); protbl.updatestock(proID, protbl.getStockInHand(proID) - quantity);
public void retrieveFromDB(int proID) { string selectcmd = "SELECT * FROM [store].[dbo].[tblproduct] WHERE [proID]='" + proID + "'"; SqlConnection con = new SqlConnection(constring); con.Open(); //SqlCommand select = new SqlCommand(selectcmd, con); //SqlDataAdapter sda = new SqlDataAdapter(select); //sda.Fill(table); con.Close(); }
int
string
using (SqlConnection con = new SqlConnection(constring)) using (SqlCommand command = new SqlCommand("SELECT * FROM [store].[dbo].[tblproduct] WHERE [proID] = @proID", con)) { command.Parameters.AddWithValue("@proID", proID); SqlDataAdapter sda = new SqlDataAdapter(command); sda.Fill(table); }
protbl.retrieveFromDB(1);
productTbl protbl = null; protbl.retrieveFromDB(1);
productTbl
productTbl protbl = new productTbl();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)