473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Insert statement to actual code

Hello,

This is my three tables in database:

Expand|Select|Wrap|Line Numbers
  1. tb_plane          tb_attributes   tb_as_plane_attributes   
  2. plane_id          attribute_id       plane_attribute_id
  3. plane_name        attribute_name     FK_plane_id
  4.                                      FK_attribute_id
  5.                                      value
  6.  
On my Form I got 1 combobox which is populated by plane_name's from tb_plane and datagridview (GrdAttributes) which is populate by all attribute_name's from tb_attributes and one extra column named "Value" where the user can put some decimal/integer values. What I need is to make Insert Button Click event to put attributes with values which wrote user to plane selected in combobox and there where in GrdAttributes did not wrote value in column Value by user did not send to tb_as_plane_attributes

I did a code to populate combbox and i prepare datagridview. Perhaps I need to check GrdAllAttributes.Rows to see values is contains after the user has entered data but I don;t know how to do that. If anyone could help will be good. That's my code

Expand|Select|Wrap|Line Numbers
  1. private SqlDataAdapter CreateDataAdapter(string sql) {
  2.     return new SqlDataAdapter(sql, conSettings.ConnectionString);
  3. }
  4.  
  5. private DataSet GetDataSet(string tableName, string sql) {
  6.     DataSet dataSet = new DataSet();
  7.     CreateDataAdapter(selectCommandText).Fill(dataSet, tableName);
  8.     return dataSet;
  9. }
  10.  
  11. private DataTable GetDataTable(string sql) {
  12.     DataTable dt = new DataTable();
  13.     CreateDataAdapter(selectCommandText).Fill(dt);
  14.     return dt;
  15. }
  16.  
  17. private void PopulatePlainComboBox() {
  18.     try {
  19.         CboPlains.DataSource = GetDataTable("SELECT plane_id, plane_name FROM tb_plane");
  20.         CboPlains.DisplayMember = "plane_name";
  21.         CboPlains.ValueMember = "plane_id";
  22.     } catch (System.Exception ex) {
  23.         string str = "Source:" + ex.Source + "\n" + "Message:" + ex.Message;
  24.         MessageBox.Show(str, "Generic Exception");
  25.     }
  26. }
  27.  
  28. private void PopulateGridByAttributes()
  29.         {
  30.             DataTable dataTable = GetDataTable("SELECT attribute_id, attribute_name FROM tb_attributes");
  31.             GrdAllAttributes.Columns.Add("attribute_name", "name of attribute");
  32.             GrdAllAttributes.Columns.Add("dd", "Value");
  33.  
  34.             foreach (DataRow row in dataTable.Rows)
  35.             {
  36.                 GrdAllAttributes.Rows.Add(row[1]);
  37.             }
  38.         }
  39.  
  40.  
Sep 29 '11 #1
0 869

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Maria | last post by:
Hello I have not used db2 in a long time, and I have this very long insert script, which is giving me an error of duplicated inserts. My question is how can I put something in the statment so...
8
by: 73blazer | last post by:
Hello, I'm looking for a way to make some of my insert templates more readable by placing comments in between the values. I cannot seem to find a way to do this with DB2, is there a way? I'm...
6
by: Lelle | last post by:
Hello ! how can i insert text containg code examples from a textbox into a database using SQL insert statment. i have no problem to just add text that dont contains code and script examples...
0
by: Qaisar_Mughal | last post by:
How we can insert a javascript code in a html page using BHO, Please help me ASAP. Thank you in advance.
2
by: Denis Correard | last post by:
I have an application that create an insert statment on the fly (it would be to complex to create stored procedures for all senarios) like: insert into Table (field1, field2,field3 ,field4 ) VALUES...
3
by: Ivan Sammut | last post by:
Hi, I have a table which the first field is an autonumber field as is also my keyfield. Now I want to know if it is possible that after I do an insert stament I can get what the value of this...
2
by: Grub | last post by:
Hi Yall... This is my objective: I want the following snip of code to insert 2 values into table 'Failures'. The first value is based on a string that a user would type into a combo box. If...
1
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
3
theimmortalmoo
by: theimmortalmoo | last post by:
my boss sent me this, I dont know how to do any kinda SQL Hey Danny, can you make a data entry form so Jane can type customers' email addresses into our database? It needs to have two fields:...
1
by: alanv | last post by:
Hello, I'm having a problem with double quotes, @ symbols and # signs. When a user submits a text field with those symboles for example, its cuts them off like so... INSERT INTO po_item SET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.