ASP
--
Questions
--
Followers
Top Experts
We read an excel file in ASP like this :
Dim ConnExcel
Set ConnExcel = CreateObject("ADODB.Connec
Set RSExcel = CreateObject("ADODB.Record
SQL = "select * from [mysel$]"
ConnExcel.ConnectionString
ConnExcel.Open
RSExcel.cursortype = 3 ' adStatic.
RSExcel.open SQL, ConnExcel
Set rs = Server.CreateObject("ADODB
sTable = "pro_produits_aav"
rs.Open sTable, db_conn_def_pr, adOpenKeyset, adLockOptimistic, adCmdTable
While Not RSExcel.EOF
response.write RSExcel("Floor") & "<br>"
RSExcel.MoveNext
Wend
The problem is that we get empty string when the Excel column "Floor" is not numeric. We did set all the cell to "text" in Excel but it does nothing.
Any idea ??
Thanks
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
While Not RSExcel.EOF
response.write cStr(RSExcel("Floor")) & "<br>"
RSExcel.MoveNext
http://support.microsoft.com/default.aspx?scid=kb;EN-US;257819
A Caution about Mixed Data Types
As stated previously, ADO must guess at the data type for each column in your Excel worksheet or range. (This is not affected by Excel cell formatting settings.) A serious problem can arise if you have numeric values mixed with text values in the same column. Both the Jet and the ODBC Provider return the data of the majority type, but return NULL (empty) values for the minority data type. If the two types are equally mixed in the column, the provider chooses numeric over text.
For example:
In your eight (8) scanned rows, if the column contains five (5) numeric values and three (3) text values, the provider returns five (5) numbers and three (3) null values.
In your eight (8) scanned rows, if the column contains three (3) numeric values and five (5) text values, the provider returns three (3) null values and five (5) text values.
In your eight (8) scanned rows, if the column contains four (4) numeric values and four (4) text values, the provider returns four (4) numbers and four (4) null values.
As a result, if your column contains mixed values, your only recourse is to store numeric values in that column as text, and to convert them back to numbers when needed in the client application by using the Visual Basic VAL function or an equivalent.
To work around this problem for read-only data, enable Import Mode by using the setting "IMEX=1" in the Extended Properties section of the connection string. This enforces the ImportMixedTypes=Text registry setting. However, note that updates may give unexpected results in this mode. For additional information about this setting, click the article number below to view the article in the Microsoft Knowledge Base:
194124 PRB: Excel Values Returned as NULL Using DAO OpenRecordset






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
...Like I say this is horrible, but it does always work.
Iain.
ConnExcel.ConnectionString
ConnExcel.Open
It does not change anything. Did we set the paramter correctly ?
- colly92002 : the idea is effectively a solution but as you say, a little horrible. Let's say we'll do it, if nothing else works.... thanks anyway.
xlsConn.Open "Provider=Microsoft.Jet.OL

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
But.... unbeleivable, no change, I still don't see the text values.....
Insure that the data in Excel is entered as text. Just reformatting the Excel column to Text will not accomplish this. You must re-enter the existing values after reformatting the Excel column. In Excel, you can use F5 to re-enter existing values in the selected cell.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I believe we will forget excel and go thru CSV as colly92002 suggests.
Thanks also to mantarae that helped us understanding the complexity of the thing.
Thanks for your participation.
ie =A1 & "added-string" then paste special the returned value of this formula over you original clean data.
The when it's in ASP land just do a replace.
stringVar = relpace(stringVar, "added-string", "")
Messy but functional.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
For Excel, the connection string is:
string.Format(@"Provider=M
@" Extended Properties=""{1}""", pathName, "Excel 8.0;HDR=YES;IMEX=1");
In the registry, set:
HKEY_LOCAL_MACHINE\SOFTWAR
and
HKEY_LOCAL_MACHINE\SOFTWAR
For CSV, the connection string is:
string.Format(@"Provider=M
@" Extended Properties=""{1}""", path, "Text;HDR=YES;FMT=Delimite
In the registry, set:
HKEY_LOCAL_MACHINE\SOFTWAR
and
HKEY_LOCAL_MACHINE\SOFTWAR
David
For excel, see mantarae's solution above, but set TypeGuessRows = 0.
ASP
--
Questions
--
Followers
Top Experts
Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.