468,146 Members | 1,537 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,146 developers. It's quick & easy.

Sending <select> to MS Access Database

1
The title says it all.
i've inserted my database tables into the select options , and now i want when the Client select options get inserted into a table.
Just to clear your minds on what is going on . i'm working on an order form that takes select options from different tables
becouse i want to make an Admin control page in the future (So he can easily controll all the addons exc).

I made 4 functions on the aspx.cx
which all call the tables on Databases and fill them with the info.
and on the Page load function i called all 4 functions (since i have 4 tables).

and i made a button to call btn function that insert tha data into the table but it seems not to be working.
Expand|Select|Wrap|Line Numbers
  1.  
  2.      <asp:Button Text="Click me to Order!" ID="MyButton" runat="server" OnClick="btn" />
  3.  
Expand|Select|Wrap|Line Numbers
  1.  public void order()
  2.         {
  3.  
  4.             Random rnd = new Random();
  5.             int id = rnd.Next(1, 123456789);
  6.             string adds3 = tosfot.Value;
  7.             string btsek3 = btsek.Value;
  8.             string size3 = size.Value;
  9.             string kind3 = kind.Value;
  10.             string name12 = name1.Text;
  11.             string phone = phonenumber.Text;
  12.             string email12 = email1.Text;
  13.             string strDb;
  14.             strDb = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Database\site.accdb;" +
  15.                     "Persist Security Info=False";
  16.             OleDbConnection conn9 = new OleDbConnection(strDb);
  17.             conn9.Open();
  18.             OleDbCommand cmd = conn9.CreateCommand();
  19.             cmd.CommandText = "INSERT INTO orders VALUES ('" + id + "','" + name12 + "','" + email12 + "','" +
  20.                               phone + "','" + btsek3 + "','" + adds3 + "','" + size3 + "','" + kind3 +
  21.                               "',120);";
  22.             cmd.ExecuteNonQuery();
  23.             conn9.Close();
  24.  
  25.  
  26.         }
Apr 10 '20 #1
0 1858

Post your reply

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

Similar topics

21 posts views Thread by nihad.nasim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.