Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sql Query with dbreader Help

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-07-05 : 17:02:58
Hi Guys,

I am using dbreader for inserting data into the table. But if there is any null value in one of the fields i am getting the message " Cast from DBNull to type string is not valid". How to get rid of this Null values.Appreciate your help. Here is my Query

SQL = "insert into tblcontract(fkcontracttype,fkgroup,fksubgroup,orderid,fkordertype,date,orderbegindate,orderenddate,fknetwork,estimatenumber,flight,donovan,fkadvertiser,fkagency,fktrafficsystem,agencycommission,buyer,fkclient,repcommission,fkproducttype,product,buydesc,fkae,fkae2,aesplit,natsplit,referencepkid)" & _
" values ('UNWIRED', '" & dbreader("fkgroup") & "','" & dbreader("fksubgroup") & "','" & dbreader("orderid") & "','" & dbreader("fkordertype") & "','" & dbreader("date") & "','" & dbreader("orderbegindate") & "','" & dbreader("orderenddate") & "','" & dbreader("fknetwork") & "','" & dbreader("estimatenumber") & "','" & dbreader("flight") & "','" & dbreader("donovan") & "','" & dbreader("fkadvertiser") & "','" & dbreader("fkagency") & "', '" & dbreader("fktrafficsystem") & "','" & dbreader("agencycommission") & "','" & dbreader("buyer") & "','" & dbreader("fkclient") & "','" & dbreader("repcommission") & "','" & dbreader("fkproducttype") & "','" & dbreader("product") & "','" & dbreader("buydesc") & "','" & dbreader("fkae") & "','" & dbreader("fkae2") & "','" & dbreader("aesplit") & "','" & dbreader("natsplit") & "','" & dbreader("pkid") & "')"

Thanks,


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-05 : 19:28:15
Duplicate post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=68696


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-07-05 : 21:24:42
saidev -- What exactly are you trying to do here? BEcause it looks like you are reading data from SQL and then, row by row, constructing SQL statements using that data and executing them to copy data *back* to the server, or something like that. If so, then you should be aware that there are much, much, much easier, shorter and more efficient ways to do this.



- Jeff
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-05 : 23:26:41
the error tells you that you cannot convert null to string

handle null values in the dbreader (which i assume is a function)
--> if it's null then just pass a blank or allow nulls in your fields

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -