Link to home
Create AccountLog in
Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to enter system date in sqlserver from parameter

HI, I have attached 3 pictures, about what i want.

Currenty, i am using a textbox to input date manually. But i want , when some one will enter data, Date will be inputed automaticaly, Date filed in Sql serger is "Date"

any advise realy would be helpfull
Avatar of divyeshhdoshi

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of fosiul01


yap done thanks divyeshhdoshi
I will close this question soon, just let me check something
Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Just one more quick questions ,

if you see in 2nd picture, in dataview1 control, then Insert (  its showing as  a text link)
how i will convert that one to a button ??

i was looking for this option for cuple of hr, but didnot find out how to convert insert from text link to button

please advise me.

I found the solution about button filed.
thanks Devastated , for additional information, that would of help me.
Why do you need to do that?

The SQL statement will automatically store the date at the moment the 'submit' the whole record button and the sql statement is fired to the database...

i.e. do you really need to allow a seperate button as a kind of timestamp functionality?
Sorry forgot to say as i stated earlier i would be tempted to simply remove the entire date parameter and anything associated with it i.e. textboxes etc, that is the date functionality would be done without any intervention from the user
NO, its nothing to do with timestamp.
i just wanted insert to apprear as  a button thats all . because in picture 2, insert is comming as a text link ( like insert -  cancel)

check the bellow picture about what i wanted.
its silly i know.
and about date parameter, i have change the code as follows :

<DataObjectMethod(DataObjectMethodType.Insert)> _
        Public Shared Sub Insertguestbook(ByVal name As String, _
                ByVal Entry_date As Date, ByVal comments As String)
        Dim ins As String = "INSERT INTO guestbook_entry " _
            & "(name, Entry_date, comments) " _
            & "VALUES(@name, @Entry_date, @comments)"
        Dim cmd As SqlCommand = _
            New SqlCommand(ins, New SqlConnection(GetConnectionString))
        cmd.Parameters.AddWithValue("name", name)
        cmd.Parameters.AddWithValue("Entry_date", System.DateTime.Now)
        cmd.Parameters.AddWithValue("comments", comments)
    End Sub

is this right , is not it ??