473,326 Members | 2,805 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,326 software developers and data experts.

Inserting a command into a database

Hi

I have the following method. HOw do I performe the task to the table in the
database?

protected void FormView1_PageIndexChanging(object sender,
FormViewPageEventArgs e)
{
Button S = sender as Button;

if (S != null)
{
TextBox Name = (TextBox) S.Parent.FindControl("tbName");
TextBox Company = (TextBox) S.Parent.FindControl("tbCompany");
TextBox Email = (TextBox) S.Parent.FindControl("tbEmail");
TextBox Subject = (TextBox) S.Parent.FindControl("tbSubject");
TextBox Message = (TextBox) S.Parent.FindControl("tbMessage");
Label ID = (Label) S.Parent.FindControl("lblID");
SqlDataSource DS = (SqlDataSource)
S.Parent.FindControl("SqlDataSource1");

SqlDataSource1.InsertCommand = "insert into Emails (ID, Name,
Company, Subject, Message ) values ( @ID, @Name, @Company, @Subject,
@Message );";
if ((Name != null) && (Company != null) && (Email != null) &&
(Subject != null) && (Message != null) && (ID != null) &&
(DS != null) )
{
SqlDataSource1.InsertParameters["ID"].DefaultValue = ID.Text
+ 1;
SqlDataSource1.InsertParameters["Name"].DefaultValue =
Name.Text;
SqlDataSource1.InsertParameters["Company"].DefaultValue =
Company.Text;
SqlDataSource1.InsertParameters["Email"].DefaultValue =
Email.Text;
SqlDataSource1.InsertParameters["Subject"].DefaultValue =
Subject.Text;
SqlDataSource1.InsertParameters["Message"].DefaultValue =
Message.Text;
}
SqlDataSource1.
}
}


Mar 3 '08 #1
0 793

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
1
by: Scott Chapman | last post by:
I am working with Python (psycopg). I have HTML with embedded Python that I'm inserting into a database and it could contain any character. Single quotes, at least, must be escaped (to two...
6
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
1
by: Nemisis | last post by:
hi guys, Currently converting an old classic asp system to a OOP asp.net application. We are building the new application using a 3 tier arcitecture and i was wondering about the following. ...
3
by: milecimm | last post by:
Hi, I want to check in the below code if the email exists in the database before inserting. How can I do that? Dim EmailAlertDataSource As New SqlDataSource() ...
4
by: azura | last post by:
how i want to check if there is duplicate entry in my database?? i insert new record which is the same record that i had inserted before,it successfull insert into the database..i don't want that.....
1
by: ayyanki | last post by:
Hello all, I'm still learning about c# and I have a major function that I need to write (in a forms application), and I have no idea how to go about it. Here's the scenario: I have a text file...
7
by: qazplm114477 | last post by:
Hi, i have a problem with a small program i wrote which adds vendors to the database. i created a windows form and made it into a dialog that adds vendors to my database. When I open the dialog to...
1
by: Formula | last post by:
Hi, i'm working on my first project on asp.net using c#. I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table. The database contains...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.