0

I have created a web form registration page with 8 different fields (Usernametb, Firstname, Surnametb, Emailtb, Mobiletb, Postcodetb, Passwordtb) (tb=text box)

I have also created a database table in Access that has the right amount of columns for each different textbox.

How would I go about successfully linking my registration form to the database so that every time a user registers, it will automatically save his information in the database? ( I need to be able to add, remove and modify people in my database)

OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C: \Users\Zee\Desktop\Computing\Comp\UserData.accdb";
cmd.Connection = con;
cmd.CommandText = "insert into [UserData](Username,FirstName,Surname,Email,Mobilenumber,Postcode,Password)values(" + Usernametb.Text + "," + Firsttnametb.Text + "," + Surnametb.Text + "," + Emailtb.Text + "," + Mobiletb.Text + "," + Postcodetb.Text + "," + Passwordtb.Text + ")";
}
Jonathan Porter
  • 1,365
  • 7
  • 34
  • 62
Zalgawi
  • 23
  • 3
  • 10
  • 3
    Ok, you have these two things, now what's the question? Also, your program is at risk for SQL injection attacks. Check [bobby-tables.com](http://bobby-tables.com) for information on them. – Erik A Nov 29 '17 at 20:06
  • How would I go about successfully linking my registration form to the database so that every time a user registers, it will automatically save his information in the database? ( I need to be able to add, remove and modify people in my database) – Zalgawi Nov 29 '17 at 20:07
  • if you are using parameters in AccessDB do you need to use `?,?,?,?` as parameters? also there are plenty of examples online in regards to how to construct an Insert statement into AccessDB – MethodMan Nov 29 '17 at 20:10
  • @MethodMan I am fairly new to all this programming, still trying to figure out how to do everything. This is just a small project that I'm working on so I wouldn't actually make my database or website fully online. So hopefully people wouldn't be able to "SQL inject" my work. – Zalgawi Nov 29 '17 at 20:12
  • regardless of that, you still want to follow best practices as to not adopt bad habits.. do a google search for what you are trying to accomplish – MethodMan Nov 29 '17 at 20:13
  • @MethodMan I have tried googling several different methods but non of them seem to work for me. A lot of the tutorials link the prorgam to SQL instead of Access, although I have to specifically do it on access. – Zalgawi Nov 29 '17 at 21:30
  • what about this one it has accepted answer in regards to what I commented on earlier.. https://stackoverflow.com/questions/15910977/insert-into-access-database – MethodMan Nov 29 '17 at 21:33
  • @MethodMan what is this character? " ?,?,?,? " – Zalgawi Nov 29 '17 at 22:13
  • it's what access uses as it's parameter.. like `@` is what the parameter token is for Sql Server.. – MethodMan Nov 29 '17 at 22:23
  • When I use the "?,?" Parameters it just comes up with errors. Also I do not have enough rep to take this to chat, is there anywhere else we can discuss this so I can provide screen shots? that might help you identify this – Zalgawi Nov 29 '17 at 22:25
  • @MethodMan Any thoughts on my previous comment? thank you – Zalgawi Nov 30 '17 at 15:04
  • can you edit your question and show how you are using the `?` these are called Parameters, you need to use the command Parameters .Add function if you update the code I can fix it for you – MethodMan Nov 30 '17 at 15:40
  • @MethodMan I've got quite a few pages open and I'm not really sure which one I'm supposed to be modifying. Is there somewhere else that we can talk on so I can provide screenshots? – Zalgawi Nov 30 '17 at 16:04
  • you need to update the initial question and put in where you said you tried using the `?` in your Insert statement.. – MethodMan Nov 30 '17 at 16:14
  • @MethodMan I haven't used the "?" in my insert statement because I don't even know what the insert statement is? Like i said, I'm really new to programming so all of these terms are new to me. – Zalgawi Nov 30 '17 at 17:16

0 Answers0