Database programming is easy with Visual Studio.Net projects, it offers a variety of methods to visualize the programming logic. Here in our example, we demonstrate how you can extract specific rows from a TableView, which is the local representation of the SQL Table/Database Table View.
First I need a table view, like
ProductTableAdapter = new SqlDataAdapter("select * from productMaster", con);
ProductTableAdapter.Fill(ProductTableDataset, "ProductMaster");
ProductTableView = new DataView(ProductTableDataset.Tables[0]);
Now I am going to find some rows for a specific product in the table view using the Find() method.
taekproduct="Citrizine Tab";
Common.ProductTableView.Sort="product";
int i = Common.ProductTableView.Find(takeproduct);
First I need to specify the Sort column which is the same column with the value I want to search. Second the product itself.
The Find() returns the row number instead of the row itself which can be used to access the row you want. If it’s 1 you can make sure you succeeded to find the row with takeproduct value otherwise the value will be -1.
Then I extract the tax rate from the table.
if (i != -1)
{ takecgst = takesgst = takeigst = 0;
double.TryParse( Common.ProductTableView[i]["cgst"].ToString(),out cgstrate);
double.TryParse(Common.ProductTableView[i]["sgst"].ToString(), out sgstrate);
double.TryParse(Common.ProductTableView[i]["igst"].ToString(), out igstrate);}
that’s all I got today.