Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Insert SQL syntax when item maybe nothing

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,51303
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Insert SQL syntax when item maybe nothing
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Insert SQL syntax when item maybe nothing - 8/29/2007 3:26:48 AM   
  Kitshing

 

Posts: 22
Score: 0
Joined: 8/12/2007
Status: offline
I need to write a SQL from VBA of Excel to insert data into Access database.

e.g.
Dim strSQL as String
Dim itemDate as String                 // user will input data that is a valid date format.  such as  29/8/2007
Dim conn as new adodb.Connection

strSQL = "INSERT INTO TEST_TB (ITEM_ID, ITEM_DATE)" & _
                    " VALUES ('item001', '" & FormatDateTime(itemDate) & "' );"

conn.execute(strSQL)

-----
But error will appear when the user no input item date
(becuase the application is allowed no input for item date fields.

* ITEM_ID is TEXT type in database
  ITEM_DATE is DATE type in database

< Message edited by Kitshing -- 8/29/2007 3:31:20 AM >
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Insert SQL syntax when item maybe nothing Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts