0 Replies - 1001 Views - Last Post: 14 April 2012 - 10:50 AM Rate Topic: -----

#1 AOM_Set   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 151
  • Joined: 18-December 10

Get user input via a textbox, and insert them in a database

Posted 14 April 2012 - 10:50 AM

Hi
I have been looking for a tutorial on how to do the mentioned (in the title)
There is a lot on how to insert values into a table, but didnt find any (Using asp.net) on how to get them from a user input. All the examples I find, the records to insert were hardcoded.

So basically, what I want to do (illustrated in C# using array).
Get input from user and insert it in an array.
String input = Console.ReadLine();
char[] value = input.ToCharArray(); 


Now the input is in the char array. Now to the more realistic part. Let's assume that the input is taken from a textbox as seen below. (Ofcourse we also have a submit button for sending the value)
<input type="text" id="valueForTheDatabase" runat="server"/>


I know how to obtain the value throug C# code in the relevant class. In the relevant class I assume we have something like this (Assume I have already written the code that creates the connection, which I know how to)
MySqlConnection connection = new MySqlConnection("...");
MySqlCommand command = connection.CreateCommand();
command.CommandText = "INSERT INTO Table (name, age) VALUES (Name given by user, Age given by user);



Now where do I go from here? If I want to get the username given in the, and insert it in the database where I have written "Name given by user and "Age given by user"?
I know how to do it if I hardcode those values.
Thanks in advance

Ps. I'm using the above for creating a simple login system to a website in ASP.NET. I have found many tutorials, but these use MS SQL and others, and the syntax is slightly different. Does anyone know a very nice tutorial on this? I know the overall idea, but I'm just struggeling with the code.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1