时间可以这样用吗?paddtime=#" & Now() & "#在vb.net(asp.net+sqlserver)里paddtime=#" & Now() & "#

解决方案 »

  1.   

    不懂楼主的意思
    可以这样起时间System.DataTime.Nows.shorttostring()
    sqlserver直接用getdate()再进行转换
      

  2.   

    上面多了点东西
    是System.DateTime.Now.ToShortDateString()
      

  3.   

    我这条是写在SQL语句里的.
    paddtime是数据库中的字段让数据库中的字段paddtime=#" & Now() & "#
      

  4.   

    Sub DataGrid1_update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
            Dim txtid, txttypeid, txtpro_id, txtpname, txtpimageurl, txtpsprice, txtphprice, txtpaddtime, txtpintro, txtcc, txtyxq As TextBox
            txtid = e.Item.Cells(3).Controls(0)
            txttypeid = e.Item.Cells(4).Controls(0)
            txtpro_id = e.Item.Cells(5).Controls(0)
            txtpname = e.Item.Cells(6).Controls(0)
            txtpimageurl = e.Item.Cells(7).Controls(0)
            txtpsprice = e.Item.Cells(8).Controls(0)
            txtphprice = e.Item.Cells(9).Controls(0)
            txtpaddtime = e.Item.Cells(10).Controls(0)
            txtpintro = e.Item.Cells(11).Controls(0)
            txtcc = e.Item.Cells(12).Controls(0)
            Dim strsql As String
            strsql = "update product set typeid='" & txttypeid.Text & "',pro_id='" & txtpro_id.Text & "',pname='" & txtpname.Text & "',pimageurl='" & txtpimageurl.Text & "',psprice='" & txtpsprice.Text & "',phprice='" & txtphprice.Text & "',pintro='" & txtpintro.Text & "',cc='" & txtcc.Text & "',paddtime=#" & Now() & "# where id=" & DataGrid1.DataKeys(CInt(e.Item.ItemIndex))
            Dim conn As New SqlConnection("server=(local);database=xf;uid=sa;pwd=997mb;")
            Dim cmd As New SqlCommand(strsql, conn)
            'Dim exp As Exception
            'Try
            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
            'Catch exp
            'Label3.Text = "发生错误,没有正常更新记录,请重新修改!"
            'End Try
            DataGrid1.EditItemIndex = -1
            Call myDataBind()
        End Sub