OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

sql statement on .csv file is reading int instead of string

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> sql statement on .csv file is reading int instead of string
Page: [1]
 
dzirkelb1

 

Posts: 1433
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
sql statement on .csv file is reading int instead of st... - 3/19/2009 11:44:16   
I am reading a .csv file and it is reading the IntNote field as numbers instead of text...so, when I do an insert into another table based on that .csv file, I am loosing all the text information. Can anyone help?


connection:
strConn = "Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=d:\inetpub\WebECIS\QuotesUpload\; HDR=Yes; Extensions=asc,csv,tab,txt; IMEX=1"
Set dbc = Server.CreateObject("ADODB.Connection")
dbc.open strConn


This is where it reads the file and does an insert into an sql table:
set rs = Server.CreateObject ("adodb.RecordSet")
ssql = "SELECT Qty, CustItem, Mfg, Part, TotQty, TargetPrice, Notes, FacMin, MinQty, StdPkgQty, CustMinQty, CustMultQty, Delivery, IntNote FROM [QuoteUpload.csv]"
rs.Open ssql, dbc, adOpenForwardOnly, adLockReadOnly

do while not rs.eof
	'response.write(rs("Part"))
	intMaxSeq = intMaxSeq + 1

	set rs1 = Server.CreateObject ("adodb.RecordSet")
	ssql = "SELECT ID, LastCost FROM INVENTORYMASTER1 WHERE ([PART #] = '"&rs("Part")&"')"
	rs1.Open ssql, dbc1, adOpenForwardOnly, adLockReadOnly
	
	if not rs1.eof then
		intPartID = rs1("ID")
		intLastCost = rs1("LastCost")
	else
		intPartID = 0
		intLastCost = 0
	end if
	
	rs1.close
	set rs1=nothing
	
	if len(rs("TotQty")) > 0 then
		intTotQty = rs("TotQty")
	else
		intTotQty = "null"		
	end if
	
	if len(rs("TargetPrice")) > 0 then
		intTargetPrice = rs("TargetPrice")
	else
		intTargetPrice = "null"		
	end if

	if len(rs("FacMin")) > 0 then
		intFacMin = rs("FacMin")
	else
		intFacMin = 0		
	end if

	if len(rs("MinQty")) > 0 then
		intMinQty = rs("MinQty")
	else
		intMinQty = "null"		
	end if	
	
	if len(rs("StdPkgQty")) > 0 then
		intStdPkgQty = rs("StdPkgQty")
	else
		intStdPkgQty = "null"		
	end if	
	
	if len(rs("CustMinQty")) > 0 then
		intCustMinQty = rs("CustMinQty")
	else
		intCustMinQty = "null"		
	end if	
	
	if len(rs("CustMultQty")) > 0 then
		intCustMultQty = rs("CustMultQty")
	else
		intCustMultQty = "null"		
	end if
	
	strIntNote = Left(StripQuotes(rs("intNote")),255)
	
	ssql = "INSERT INTO [QUOTES DETAIL] "
	ssql = ssql & " (Notes, [QUOTE #], Qty, [CUST ITEM #], MFG, [PART #], SEQ, TotQty, PartID, [DEE COST], Turns, WgtFctr, TargetPrice, FacMin, MinQty, StdPkgQty, CustMinQty, CustMultQty, Delivery, IntNote)"
	ssql = ssql & " VALUES ('"&StripQuotes(Left(rs("Notes"),100))&"', "&intQuoteNum&", '"&StripComma(rs("Qty"))&"', '"&left(rs("CustItem"),50)&"', '"&left(rs("Mfg"),50)&"', '"&StripQuotes(left(rs("Part"),50))&"', "&intMaxSeq&", "&StripComma(intTotQty)&", "&intPartID&", "&intLastCost&", 4.5, .003, "&StripComma(intTargetPrice)&", "&StripComma(intFacMin)&", "&StripComma(intMinQty)&", "&StripComma(intStdPkgQty)&", "&StripComma(intCustMinQty)&", "&StripComma(intCustMultQty)&", '"&Left(StripComma(rs("Delivery")),50)&"', '"&StripComma(strIntNote)&"')"
	response.write(ssql&"<br><br>")
	dbc1.execute(ssql)
rs.moveNext
Loop


Any ideas what the deal is? An example of data would be:

actual data: 0.645 allied
imported data: 0.645

it chopped off the allied portion, but wierd is it kept the 0 of 0.645.
BeTheBall

 

Posts: 6493
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: sql statement on .csv file is reading int instead o... - 3/19/2009 14:16:39   
See if this helps any:

strIntNote = Left(StripQuotes(rs("intNote")),255)&""

That should ensure the variable is interpreted as a string.


_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to dzirkelb1)
dzirkelb1

 

Posts: 1433
Joined: 10/5/2004
From: Cedar Rapids, Iowa
Status: offline

 
RE: sql statement on .csv file is reading int instead o... - 3/19/2009 14:41:39   
Its not the variable that is the string, if I response.write the rs("IntNote") before I turn it into a variable, then it looses the text in the field...I need the connection string to force a string on the field.

(in reply to BeTheBall)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> sql statement on .csv file is reading int instead of string
Page: [1]
Jump to: 1





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