• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

asp.net : how to insert timestamp data type into sql server db

mutantx511

New Member
hi,

im new in asp.net n im having probs inserting a timestamp data type into my sql server db. can anybody help?

thanks.
 
this is my code for inserting the data. there are 3 fields that are
with timestamp data type;
1. taggingTime
2. lastActvTime
3. purTime

thanks..

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim oConn As OleDbConnection
Dim oComm As OleDbDataAdapter
Dim ConnectionString As String
Dim sComm As String
Dim oDataSet As New DataSet
Dim oDataSet03 As New DataSet

'SQLstring insert
sComm = "INSERT INTO linen "
sComm += "(tagID,status,taggingTime,"
sComm += "lastWashLoc,lastActvID,lastActvTime,"
sComm += "type,supplier,purTime) "
sComm += "VALUES "
sComm += "(' " & TextBox1.Text & " ',' " & TextBox2.Text & " ',' " & TextBox3.Text & " ',"
sComm += "' " & TextBox4.Text & " ',' " & TextBox5.Text & " ',' " & TextBox8.Text & " ',"
sComm += "' " & DropDownList1.SelectedValue & " ',' " & DropDownList2.SelectedValue & " ',' " & TextBox9.Text & " ')"

'Error handling
Try
'Create the connection and command objects
oConn = New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
oComm = New OleDbDataAdapter(sComm, oConn)
oComm.Fill(oDataSet03, "linenn")
Catch ex As Exception
Label3.Text = ex.ToString()
Finally
oComm.Dispose()
oConn.Close()
End Try
End Sub
 
the error was ;

System.Data.OleDb.OleDbException: Disallowed implicit conversion from data type varchar to data type timestamp, table 'eMaS.dbo.linen', column 'taggingTime'

but.. well since the timestamp data type was giving me probs, so i changed the fields to datetime type. n can insert with no errors now. i think its like u said, i got the format wrong. hmm think i shouldnt use timestamp data type in the first place. :biggrin2:

but thanks. :)

another q. do u know how to make all values in the textboxes go back to blanks, after i submit n insert data in db?

i tried dataset.clear() n dataset.reset(), but the values r still there after i insert in db.

thanks.
 
thanks.. :) but some of my forms r with lots of textboxes n all, so i tried
response.redirect to the forms back, n it worked. so oki dokie. but thanks.. :)
 
Back
Top