hi...
can you tel me how to insert null values in Access table using Vb code....
actually i want to store record having some fields with null values...plz....... i mean error is in query statement... saying "Invalid use of null value.." ... :)
8 11115
Hi
try to use this Query of inserting the value of Access Table
insert into tablename values('" & null & "'" & "'")
why r u inserting NULLS? If u wants to insert NULL in a column, don't insert value for the said field. instead of this field, insert values for other columns.
i.e. u have table with A, B, C, D columns, and if u want to insert NULL into B, then use
Insert Into <Table Name> (A, C, D) Values (<Values for A>, <Values for C>, <Values for D>
Mahesh
:) :) :)
sashi 1,754
Recognized Expert Top Contributor
hi here,
the best practise will be defining a default value during the design time of your table.. let it take care the rest.. take care..
why r u inserting NULLS? If u wants to insert NULL in a column, don't insert value for the said field. instead of this field, insert values for other columns.
i.e. u have table with A, B, C, D columns, and if u want to insert NULL into B, then use
Insert Into <Table Name> (A, C, D) Values (<Values for A>, <Values for C>, <Values for D>
Mahesh
:) :) :)
What if there is a value in B
and i want to put a null value in B
at this point i cant update it
not unless i use to insert this value=" " to B
If you are passing the variables to a dataset its "dbnull.value"
daTableAdapter.Insert(PK.tostring, Column2Data.2String, dbnull.Value)
You might be able to concatenate it into a string update query as well
hi...
can you tel me how to insert null values in Access table using Vb code....
actually i want to store record having some fields with null values...plz....... i mean error is in query statement... saying "Invalid use of null value.." ... :)
try passing the null value (access keyword) as a string in the sql query
i.e.
sql1="INSERT INTO tblMiTabla (Col1,Col2,Col3,Col4)
sql2="VALUES (" & var1 & "," & var2 & "," & IIf(IsNull(var3),"Null",var3) & ")"
where var1,var2,var3,var4 are variable names
What if there is a value in B
and i want to put a null value in B
at this point i cant update it
not unless i use to insert this value=" " to B
Becarefully using of Null value. GMan_OOph have right way for inserting Null value. But this happent if B field type are text, datetime, or several other types. If B field type are number, Yes/No, they have default values so that u cant let it Null by this way. U must use - INSERT INTO TableName(A,B,C,D) VALUES(" & a & ",Null," & c & "," & d & ")"
When Updating Null value, if u replace old value by new value, so there is no problem. But if u plant add new value into old value, so u must check it first. -
sql = "SELECT * FROM tableName"
-
if rs.state<> 0 Then rs.Close
-
rs.Open sql, cnxn, 1,3
-
If isNull(rs.Fields("B") Then
-
rs.Fields("B") = newValue
-
Else
-
rs.Fields("B") = rs.Fields("B") + newValue
-
End If
-
rs.Update
-
Remember, in ur database, select Require = No, and AllowNull = Yes for this field before u can set Null value for it.
hi...
can you tel me how to insert null values in Access table using Vb code....
actually i want to store record having some fields with null values...plz....... i mean error is in query statement... saying "Invalid use of null value.." ... :)
- strSql=""
-
strSql="Insert Into" & <Table Name>
-
strSql=strSql & "(A"
-
strSql=strSql & iif(isNull(<Values for B>), "", ",B")
-
strSql=strSql & iif(isNull(<Values for C>), "", ",C")
-
strSql=strSql & iif(isNull(<Values for D>), "", ",D")
-
strSql=strSql & ") Values (" & <Values for A>
-
strSql=strSql & iif(isNull(<Values for B>), "", "," & <Values for B>)
-
strSql=strSql & iif(isNull(<Values for C>), "", "," & <Values for C>)
-
strSql=strSql & iif(isNull(<Values for D>), "", "," & <Values for D>)
-
strSql=strSql & ")"
I think this will help you
Sign in to post your reply or Sign up for a free account.
Similar topics
by: GreenFROG Design |
last post by:
Data Processing and SQL INSERTING
Hello guy's i'm faced with a horrible dilemma i have whole dictionary that i
have to enter into a database. I have all the text and i would like to
convert it...
|
by: Marko Poutiainen |
last post by:
Situation:
We had to make our SQLServer 2000 database multi-lingual. That is, certain
things (such as product names) in the database should be shown in the
language the user is using (Finnish,...
|
by: Andrew Banks |
last post by:
I'm running the following code in a C#.NET page and it doesn't enter the
values into the DB. I'm certain the problem is to do with the txtBirth
field. It allows users to enter a DOB as dd/mm/yyyy...
|
by: Charles Wilt |
last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access
via a linked server from SQL Server 2000.
The following select works fine:
select * from...
|
by: ing42 |
last post by:
I have a problem with inserting records into table when an indexed view
is based on it.
Table has text field (without it there is no problem, but I need it).
Here is a sample code:
USE test
GO...
|
by: ebindia0041 |
last post by:
This is like the bug from hell. It is kind of hard to explain, so
please bear with me.
Background Info: SQL Server 7.0, Asp.net 1.1 with c#
I'm inserting simple records into a table. But one...
|
by: Oonz |
last post by:
Hi Friends,
How can we insert records in sorted order
like consider a table
No Name Phone
1 test1 12345
1 test1 23455
2 test2 68638
|
by: gp |
last post by:
I am and have been using PDO for about a year now...and have finally
gotten around to solving the "DB NULL value" issues I ran into early
on...
I am looking for suggestions and techniques to...
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography...
|
by: aeblank |
last post by:
THE PROBLEM
I'm running into performance issues generating and storing a randomly created graph in a SQL Server database. I have a T-SQL script that generates a graph, and then randomly connects the...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |