Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2005, 09:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default getdate Not Working

I have a table with a datetime field with default value set to (getdate()) but when I insert a record from my ASP.NET page it doesn't put anything in the field (leaves it null). If I change the option for "Allow nulls" I get an error...

???

-------------------------
Beware of programmers with screwdrivers...
__________________
-------------------------
Beware of programmers with screwdrivers...
 
Old July 15th, 2005, 01:58 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

can you post your ASP.NET code?

 
Old July 15th, 2005, 02:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

Dim objConn As SqlConnection
        Dim objAdapter As SqlDataAdapter
        ' Dim objTable As DataTable
        Dim objNewRow As DataRow
        Dim objBuilder As SqlCommandBuilder

        objConn = New SqlConnection(m_connString)
        objAdapter = New SqlDataAdapter("Select * from tblExam", objConn)
        objAdapter.FillSchema(m_Dataset, SchemaType.Source)
        objNewRow = m_Dataset.Tables(0).NewRow()
        objNewRow.Item("Name") = m_ExamName
        objNewRow.Item("IDP") = m_IDP
    m_Dataset.Tables(0).Rows.Add(objNewRow)
        objBuilder = New SqlCommandBuilder(objAdapter)
        objAdapter.InsertCommand = objBuilder.GetInsertCommand
        objAdapter.UpdateCommand = objBuilder.GetUpdateCommand
        If objAdapter.Update(m_Dataset.Tables(0)) >= 1 Then
            Return 1
        Else
            Return 0
        End If

-------------------------
Beware of programmers with screwdrivers...
 
Old September 7th, 2005, 08:24 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think dot net helps your by thinking you forgot to send a value and thus sends a null. What happens if you set the table to not allow nulls. I believe the problem is on the dot net side of things. Question is how to get dot net to not help you I believe.

 
Old September 7th, 2005, 11:31 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Can you post the code for objBuilder.GetInsertCommand?






Similar Threads
Thread Thread Starter Forum Replies Last Post
GETDATE? drachx SQL Server 2000 2 February 17th, 2005 08:05 AM
Convert getdate() -> dd/mm/yyyy? minhpx SQL Language 1 January 3rd, 2005 09:30 AM
Using GETDATE in an In-Line function Mitch SQL Server 2000 13 March 25th, 2004 08:46 AM
seconds missing in getdate() stufflebeem SQL Server 2000 1 October 24th, 2003 04:52 PM
GETDATE() dose not......... arshad mahmood SQL Server 2000 2 August 19th, 2003 07:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.