How to store time from DTPicker in SQLServer 2000

elearnindia

New member
Joined
Mar 3, 2010
Messages
4
Programming Experience
1-3
How to store time from DTPicker in SQLServer 2000 when the front end is in VB2005.I am using the following code:-
In the add form:-
VB.NET:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim dsNewCustomer As DataSet = DataAccess.AuthorData.DataModule.GetNewAuthor

        Dim frm As New frmAuthor
        frm.MainForm = Me
        frm.LoadData(dsNewCustomer)
        frm.txtAuthorid.ReadOnly = False
        frm.ShowDialog()
    End Sub

GetNewAuthor() Function is in DataAcces DLL:-

VB.NET:
Public Function GetNewAuthor() As DataSet
        Dim conn As SqlConnection = Me.GetConnection()
        Try
            Dim strSQL As String = "Select * from newauthor where au_id = ''"
            Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, conn)
            Dim ds As New DataSet
            Try
                da.Fill(ds, "newauthor")
                Dim dr As DataRow = ds.Tables(0).NewRow
                ds.Tables(0).Rows.Add(dr)
            Finally
                da.Dispose()
            End Try
            Return ds
        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Function

Save uses the following code:-

VB.NET:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        BindingContext(dsAuthor, "newauthor").EndCurrentEdit()
        DataAccess.AuthorData.DataModule.SaveAuthor(dsAuthor)

        MainForm.LoadData()
        Me.Close()
    End Sub

Time is not getting stored in SQLServer2000 database.Any kind help will be appreciated
 

demausdauth

Well-known member
Joined
Mar 24, 2008
Messages
281
Location
Minnesota
Programming Experience
3-5
We need to see code for SaveAuthor since that is where it would be sending the values to the SQL server.
 

elearnindia

New member
Joined
Mar 3, 2010
Messages
4
Programming Experience
1-3
Code of SaveAuthor() sub

Thanks for looking at my question,SaveAuthor() sub is in DataAcesses DLL it contains the following code:-

VB.NET:
    Public Sub SaveAuthor(ByVal ds As DataSet)
        'Update a dataset representing authors
        Dim conn As SqlConnection = GetConnection()

        Try
            Dim strSQL As String = "select * from newauthor"
            Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, conn)

            Try
                Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
                If ds.HasChanges Then
                    da.Update(ds, "newauthor")
                    ds.AcceptChanges()
                End If
            Finally
                da.Dispose()
            End Try

        Finally
            conn.Close()
            conn.Dispose()
        End Try

    End Sub

waiting for your kind reply.
 
Top Bottom