I have a datetime field in table.
I want to insert the current time of database server to the table thr
ASP.NET (C#).
I have dataset to do the insert:
DataSet1.TableNameRow rowNew =
(DataSet1.TableNameRow)DataSet1.TableName.NewRow() ;
rowNew.DateTimeField = System.DateTime.Now;
(rest of the code..)
I would like to ask in the second line of the code, I can insert the current
time of the web server to the DateTimeField,
However if I want the time refer to the current time of the SQL server, i.e
the GETDATE() of MS SQL , what should I write?
I can't type
rowNew.DateTimeField = "GETDATE()";
Thanks for any help. 3 3638
The Dataset is not meant to be used to update in this way. First of all, the
dataset don't have a clue what SQL Server is, therefore, GETDATE() will not
work. Secondly, this is not the most effecient way to do an update.
Insert this date using the SqlConnection and SqlCommand objects while
constructing your sql string.
"j@son.c" wrote: I have a datetime field in table.
I want to insert the current time of database server to the table thr ASP.NET (C#).
I have dataset to do the insert:
DataSet1.TableNameRow rowNew = (DataSet1.TableNameRow)DataSet1.TableName.NewRow() ; rowNew.DateTimeField = System.DateTime.Now; (rest of the code..)
I would like to ask in the second line of the code, I can insert the current time of the web server to the DateTimeField, However if I want the time refer to the current time of the SQL server, i.e the GETDATE() of MS SQL , what should I write?
I can't type
rowNew.DateTimeField = "GETDATE()";
Thanks for any help.
On 19 Feb 2005, "=?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?="
<Ta***********@discussions.microsoft.com> postulated in
news:65**********************************@microsof t.com: The Dataset is not meant to be used to update in this way. First
of all, the dataset don't have a clue what SQL Server is, therefore, GETDATE()
will not work. Secondly, this is not the most effecient way to do an
update. Insert this date using the SqlConnection and SqlCommand objects
while constructing your sql string.
"j@son.c" wrote:
I have a datetime field in table.
I want to insert the current time of database server to the table
thr ASP.NET (C#).
I have dataset to do the insert:
DataSet1.TableNameRow rowNew = (DataSet1.TableNameRow)DataSet1.TableName.NewRow() ; rowNew.DateTimeField = System.DateTime.Now; (rest of the code..)
I would like to ask in the second line of the code, I can insert
the current time of the web server to the DateTimeField, However if I want the time refer to the current time of the SQL
server, i.e the GETDATE() of MS SQL , what should I write?
I can't type
rowNew.DateTimeField = "GETDATE()";
Thanks for any help.
You cannot directly access SQL server batches in an ASP.NET script.
You must interface to SQL server through ADO.NET, which provides
classes, like SqlConnection and SqlCommand that provide access to the
data server.
Look at some of the examples describing server-side data access in
the ASP.NET examples: http://samples.gotdotnet.com/quickstart/aspplus/
-- ipgrunt
Typically, you wouldn't do this in .NET. You'd do it in your database.
Just set the default value for your datetime column to getdate()
Then, just don't reference the column in your insert statement.
If you are using stored procedures, you'd just update the column
with getdate() on update calls.
--
2005 Microsoft MVP C#
Robbe Morris http://www.robbemorris.com http://www.mastervb.net/home/ng/foru...t10017013.aspx http://www.eggheadcafe.com/articles/..._generator.asp
<j@son.c> wrote in message news:eS**************@tk2msftngp13.phx.gbl... I have a datetime field in table.
I want to insert the current time of database server to the table thr ASP.NET (C#).
I have dataset to do the insert:
DataSet1.TableNameRow rowNew = (DataSet1.TableNameRow)DataSet1.TableName.NewRow() ; rowNew.DateTimeField = System.DateTime.Now; (rest of the code..)
I would like to ask in the second line of the code, I can insert the current time of the web server to the DateTimeField, However if I want the time refer to the current time of the SQL server, i.e the GETDATE() of MS SQL , what should I write?
I can't type
rowNew.DateTimeField = "GETDATE()";
Thanks for any help. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jack |
last post by:
I have a text file of data in a file (add2db.txt) where the entries are
already entered on separate lines in the following form:
INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
|
by: shank |
last post by:
I have a recordset that contains multiple records of product a user is
purchasing. For clarity, I converted the recordset fields to variables. I
need to take that entire recordset and insert it...
|
by: Robin Lawrie |
last post by:
Hi again, another problem!
I've moved from an Access database to SQL server and am now having trouble
inserting dates and times into seperate fields. I'm using ASP and the code
below to get the...
|
by: Josué Maldonado |
last post by:
Hello List,
I'm importing some data from Foxpro to Postgres, there is atable wich
contains aprox 4.8 million rows and it size about 830MB. I uploaded it
to Postgres using dbf2pg and worked fine,...
|
by: dunleav1 |
last post by:
I have a process that does inserts that runs 50% slower that Oracle and
Mssql.
Queries normally take 50% slower than normal.
DB2, Oracle, Mssql all are configured on same os, same disk array...
|
by: David Eades |
last post by:
Hi all
Complete newbie here, so apologies if this is the wrong forum.
I've been asked to use mysql and asp to make a simple bidding system (rather
like a simple ebay), whereby users can use a...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am...
|
by: MLH |
last post by:
Suppose, in a multi-user environment, you
have append query SQL in a VBA procedure
that looks like INSERT INTO MyTable...
and the next line reads MyVar=DMax("","MyTable...
You can never be...
|
by: =?Utf-8?B?bXBhaW5l?= |
last post by:
Hello,
I am completely lost as to why I can't update a DropDownList inside a
DetailsView after I perform an insert into an object datasource. I tried to
simply it down to the core demostration:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |