Showing posts with label stamp. Show all posts
Showing posts with label stamp. Show all posts

Monday, March 19, 2012

adding sql db

hey i have a very simple form here:www.syscpupower.com

I would like to have the information from the form saved to a sql db with a time stamp.

here is the code i have for the page below:

"C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >"server"> "form1" runat="server">


"z-index: 108; left: 0px; position: absolute; top: 189px">

"z-index: 109; left: 204px; width: 411px; position: absolute; top: 18px; height: 160px">"3" rowspan="3" style="text-align: center"> Please accept to view your detailed trip information.

"Button1" runat="server" OnClick="Button1_Click" Style="z-index: 102; left: 322px; position: absolute; top: 261px" Text="Accept" Width="60px"> "Button2" runat="server" OnClick="Button2_Click" Style="z-index: 103; left: 392px; position: absolute; top: 261px" Text="Decline" Width="64px"> "Label1" runat="server" Style="z-index: 104; left: 254px; position: absolute; top: 198px" Text="Please Enter Your First and Last Name!" Width="273px"> "TextBox1" runat="server" Style="z-index: 105; left: 278px; position: absolute; top: 229px" Width="216px"> "RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="FirstName LastName" Font-Size="12px" Style="z-index: 106; left: 500px; position: absolute; top: 229px">* "ValidationSummary1" runat="server" Style="z-index: 110; left: 263px; position: absolute; top: 300px" Width="284px">

sorry, what exactly you want?

you want to know how to insert information to db?

or you want to know how to create db for it?

|||well i created the db, now i guess i need to findo out how to get the info from the text box into the database...|||

using (SqlConnection sc = new SqlConnection("Data Source=(local);Initial Catalog=AAAA;Integrated Security=SSPI;"))
{

string strSQL = "INSERT INTO tbXXXX(NAME) VALUES(TextBox1.text)
SqlCommand command = new SqlCommand(strSQL, sc);
command.Connection.Open();
command.ExecuteNonQuery()
}

|||

i have added the SQL database, THATS it...

I see the code that you have put here can you please explain the coding, how did you get this and where does it go in the coding. alsodi i need to create tables inside my db.

|||

Hey

You could double click button in design mode and add above code.

Above code follows those steps:

Create a connection -> build the sql -> create sql command ->open connection ->exec insert-> close command.

And to prevent Sql Inject you could choose sql parameter,it could be something like this:

SqlCommand cmd = new SqlCommand("select column1 from test where column1 = @.column1", conn);

cmd.Parameters.AddWithValue("@.column1", str_test);

If you are in trouble understanding the codeStarter Books might be helpful.

Thursday, February 9, 2012

Adding a time stamp to the records

I have a shopping cart that will get full from time to time because
customers click out of the site before they confirm their purchase,
therefore leaving a full cart behind. I'd like to have a timestamp on
this table, so that I can delete anything that I find is more than a day
old.

How can I do this?

Thanks,

Bill

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi

You could use a not null datetime field and specify the default as
getdate(). This will insert the current date/time when the record is
created. and you will not have to specify a value. You can then run a
scheduled task (job) that checks for entries older than a given date.

John

"Bill" <BillZimmerman@.gospellight.com> wrote in message
news:3f4fe28e$0$62083$75868355@.news.frii.net...
> I have a shopping cart that will get full from time to time because
> customers click out of the site before they confirm their purchase,
> therefore leaving a full cart behind. I'd like to have a timestamp on
> this table, so that I can delete anything that I find is more than a day
> old.
> How can I do this?
> Thanks,
> Bill
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!