Click to See Complete Forum and Search --> : web form -> SQL database
aegiss
05-27-2006, 11:02 PM
Hey, i have a simple question i hope someone can help me with. basically I just want to take the information from a simple web form and put that information into my SQL database when they click submit. im pretty familiar with SQL i'm just not sure how to get started with the web aspect. So say i have a form like this
<form id="web_request" name="web_request" method="post" action="">
<label>Band :
<input name="band" type="text" value="" />
</label>
<br />
<label>Song :
<input name="song" type="text" value="" />
</label>
<input type="submit" value="Submit">
</form>
Any idea of what SQL command I'd put now to upload that info to my database when they click submit? or maybe something i need to create and put in the action part? Thanks alot :)
chazzy
05-27-2006, 11:09 PM
you would need a server side language that the form data would be posted to, such as ASP/Java/ASP.NET w/ C# etc
.netjunkie
11-09-2009, 03:30 AM
Needing a server side language is not enough information. I have the same exact question and I cannot, for the life of me, find an answer. I've created a form that (upon clicking the submit button) enters the form's data into a submitted email. But I, too, am uncertain what code is needed in order to submit the form's data into a SQL database. I was THINKING that it could be as follows:
SqlCommand cmd = new SqlCommand;
cmd.CommandText="Insert Into TableName (FirstName, LastName, AnotherSqlColumnName) Values (txtFirstName.Text, txtLastName.Text, txtThirdASP.NETTextBoxID.Text)";
If anyone can follow what I'm trying to do here, that would be nice. If you know some SQL, then you can see that the "TableName" is, obviously, the name of the SQL table I created, "FirstName, LastName, AntherSqlColumnName" are three columns in my SQL table and "txtFirstName.Text...ect. are the user inputted text entered into 3 ASP.NET textboxes.
Now that I explained the obvious, can anyone tell me (and the fellow that originally asked this question) whether this will work?
A concern for me is that the SQL code above TECHNICALLY requires single quotes around the Values given..BUT, of course, I do not wish to insert the words as they are written; but I wish to, again, put the inputted text.
I'm going to experiment with this. But I'd like to know what I'm doing wrong (if anything). If, indeed, another language is necessary, I do C#. What code would I need?
Thank u.
James .netjunkie :)
.netjunkie
11-09-2009, 03:34 AM
O, SNAP, this post was originally made in '06!? Well anyhooo, I need help, fellas
ssystems
11-11-2009, 02:14 PM
You might want to check this out.
MSDN THREAD (http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/91bd10ce-c83b-4766-920b-2137ddc29908)