User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 391,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,864 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 269 | Replies: 2
Reply
Join Date: Apr 2008
Posts: 16
Reputation: hell_tej is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
hell_tej hell_tej is offline Offline
Newbie Poster

How to insert NULL using SQL (Hardest Question)

  #1  
32 Days Ago
Hi,

I m inserting Record in Access using VB6 SQL statement as follows

Dim str As String
On Error GoTo solve
str = "INSERT INTO [compinfo]([cID],[cname],[address],[add2],[city],[Postno],[mob],[phno],[faxno],[email],[workday],[offtime],[saldate],[duedate],[amount],[paytyp],[web],[type],[expdat],[charge]) values (" & "'" & txtcomid.Text & "'" & _
            "," & "'" & txtcomnam.Text & "'" & "," & "'" & txtcomadd.Text & "'" & "," & "'" & txtcomadd2.Text & "'" & _
            "," & "'" & txtcity.Text & "'" & _
            "," & txtposton.Text & _
            "," & "'" & txtmob.Text & "'" & _
            "," & "'" & txtphone.Text & "'" & _
            "," & txtfax.Text & _
            "," & "'" & txtemail.Text & "'" & "," & "'" & Comwday.Text & "'" & _
            "," & "'" & txtofftim.Text & "'" & _
            "," & Comsaldat.Text & _
            "," & "'" & DTPpay.Value & "'" & _
            "," & Txtamount.Text & _
            "," & "'" & Compaytyp.Text & "'" & _
            "," & "'" & txtwebadd.Text & "'" & _
            "," & "'" & Comtype.Text & "'" & _
            "," & "#" & expdat.Value & "#" & _
            "," & "'" & Comchar.Text & "'" & ")"
    
            
con.Execute str
solve:
If Err.Number = -2147217900 Then
MsgBox "Enter All the Fields...", vbCritical
On Error GoTo solve
Else
MsgBox "Your Record Has Been Addedd Successfully . . . ", vbInformation
End If

But this statement does not allows me Leave Blank Text boxes means
it does not allows me to insert NULL value
if i leave any textbox BLANK it generate ERROR -2147217900

HOW to solve this Problem, In my project it is not necessary to insert all records.
when we leave blank Text box it genrate Error

So PLEASE send me code or IDEA to solve this problem
Thanks for Reading My Question
Last edited by hell_tej : 32 Days Ago at 1:43 pm. Reason: Code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Location: Tulsa
Posts: 37
Reputation: khess is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
Staff Writer
Featured Blogger
khess's Avatar
khess khess is offline Offline
Light Poster

Re: How to insert NULL using SQL (Hardest Question)

  #2  
32 Days Ago
Look in your Access database. Check the attributes of the fields for the columns...check allow NULL values. This should solve it. Then you can insert a NULL value easily.
Ken Hess
Linux Blogger/Columnist
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: How to insert NULL using SQL (Hardest Question)

  #3  
31 Days Ago
what happens if you insert NULL to the field ?

is there any constraints on the database table fields.
Share your Knowledge.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 10:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC