Click here to Skip to main content
15,896,522 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All
how to insert empty vlaue in access db.the following is used for get data from anther database and store in dt,form dt i will insert into new db,so i cant tell both coloumn have value,one time Department have and deptid not have value.in this time i need to insert department value and deptid as empty value

VB
For Each row As DataRow In dt.Rows
                        Dim con2 As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\admin\Desktop\Clean OCR DB\KM.mdb;Persist Security Info=False;Jet OLEDB:Database Password= Pa$$w0rd!238;")
                        Dim cmd As OleDbCommand = New OleDbCommand("insert into Department([Department],[DeptID]) values(" + dt.Rows(0)("Department").ToString + "," + dt.Rows(0)("DeptID").ToString + ")", con2)
                        con2.Open()
                        cmd.ExecuteNonQuery()
                        con2.Close()
                        cmd.Dispose()
                    Next


pls reply me asap

Regards
Aravind
Posted
Comments
Thomas ktg 21-Nov-13 4:52am    
Does this code show any error?
Maciej Los 21-Nov-13 18:14pm    
Show us the structure of Department table. Shortly describe the fields properties.

Make sure column is allow Nulls
 
Share this answer
 
do you require your "deptid" to auto increment?
if yes try:
deptid int NOT NULL PRIMARY KEY IDENTITY(1, 1)

else try
deptid varchar(128) NULL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900