Datetimestamp Into Db

May 6, 2007

as you can see i am trying to figure out how to get the users IP address and a datetimestamp into my db. can anyone assist. i tried to comment out the datetimestamp but the iprequest does not work either.

The site i am workingon is papertrailinvites.com the newsleter on the left hand side there. i am trying to collect the email address, ip address and a datetimestamp. inserting the email address works now i just need to get the ipaddress and the datetimestamp in the db

code is below

Thanks 

 

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["cardsConnectionString1"].ConnectionString)) {

String newemail = Newsletter_Email.Text;

 

SqlCommand cmd = new SqlCommand("INSERT INTO Email (EmailAddress, IPAddress, DateTimeStamp) Values (@EmailAddress, @IPAddress, @DateTimeStamp)", conn);

cmd.CommandType = CommandType.Text;

cmd.Parameters.AddWithValue("@EmailAddRess", newemail);

cmd.Parameters.AddWithValue("@IPAddress", HttpContext.Current.Request.UserHostAddress);

//cmd.Parameters.AddWithValue("@DateTimeStamp",

conn.Open();

cmd.ExecuteNonQuery();

 

 

View 1 Replies


ADVERTISEMENT

Problems Inserting DateTimeStamp Into Database

Sep 26, 2006

Here's the error I get trying to run the code posted below..."Prepared statement '(@datestamp datetime,@PrevValue real,@NewValue real,@IPaddress r' expects parameter @datestamp, which was not supplied."I've tried it without the quotes around the DateTime.Now and also adding the # around them.  Without the quotes, I do get a different error because it doesn't like the spaces in the DateTime text.  Also, the datestamp data in the database is formatted as a datetime (MS SQL Server 2005).Here's my code:Private Sub UpdateRefresh()UpdateConnection.Open()UpdateDataAdapter.InsertCommand.CommandText = "INSERT INTO dbo.tbDeploy(datestamp," & _"PrevValue, NewValue, IPaddress, HighCapability, LowCapability, Share) VALUES" & _"('" & DateTime.Now & "', '" & lblCurrent.Text & "', '" & lblCurrent.Text & _"', '" & lblIP.Text & "', '" & lblHigh.Text & "', '" & lblLow.Text & "', '" & lblShare.Text & "')"UpdateDataAdapter.InsertCommand.ExecuteNonQuery()UpdateConnection.Close()End Sub

View 1 Replies View Related

Derived Column - DateTimeStamp From String (dd-mmm-yy)

Jun 7, 2006

I have come across something strange. I was wondering anyone else had the same problem or is it me?

I have a source file as shown below:
1,30-Feb-06,3,Test
2,20-Feb-06,5,Test1

Second column is defined as String(9) in the flat file source. Then I have a Derived Column between source and Trash destination. The Derived Column adds a new column to the datd flow. The expression is as shown below :
(DT_DBTIMESTAMP)(SUBSTRING(Col2,1,2) + "/" + SUBSTRING(Col2,4,3) + "/" + SUBSTRING(Col2,8,2))

The data is loading into the database successfully, where I was expecting it to fail. I placed a data viewer and saw the following result set.

Source (Col2) Derived Col
------------------- ------------------
30-Feb-06 06/02/1930 00:00:00 - WRONG result set
20-Feb-06 20/02/2006 00:00:00 - RIGHT result set

Can anyone repeat this problem or am I missing something? I have got SP1 and Hotfix installed.

Thanks

Sutha

View 1 Replies View Related

Transact SQL :: Date Loop Returning Min And Max Datetimestamp

Oct 21, 2015

I have a requirement for the following query which uses a timestamp data type field

[eventdate]Select field1, fileds2, filed3, {min(eventdate) as max(eventdate) per day/date} from sometable

View 4 Replies View Related

SQL Server 2014 :: Insert Stored Procedure Output To Table And Add Datetimestamp

Jun 22, 2015

I have a need to insert stored procedure output a table and in addition to that add a datetimestamp column.. For example, Below is the process to get sp_who output into Table_Test table. But I want to add one additional column in Table_test table with datetimestamp when the procedure was executed.

insert into Table_Test execute sp_who

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved