473,379 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

ASP, Excel and SQL Replace function

Hello,

Is it possible to use Replace function in a query against an
excel file?

I am trying this test code and gives me an error:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath('file.xls') & ";" & "DRIVER={Microsoft
Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstCmd = "SELECT REPLACE('abc', 'a', 'x') AS X"
rstExcel.Open rstCmd, cnnExcel, adOpenStatic, adLockPessimistic
Response.Write rstExcel("X")
Response.End

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/search/default.asp, line 26

Is there a driver limitation or is something i do wrong?

Thanks

Adrian Zaharia
Jul 22 '05 #1
5 8711
adrian zaharia wrote:
Hello,

Is it possible to use Replace function in a query against an
excel file?

I am trying this test code and gives me an error:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath('file.xls') & ";" &
"DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstCmd = "SELECT REPLACE('abc', 'a', 'x') AS X"
rstExcel.Open rstCmd, cnnExcel, adOpenStatic, adLockPessimistic
Response.Write rstExcel("X")
Response.End

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/search/default.asp, line 26

Is there a driver limitation or is something i do wrong?

Thanks

Adrian Zaharia


This error message is referring to the cursor and locktypes you chose. It
obviously cannot support a static cursor with pessimistic locking. I've
never used this so I don't know what cursor and lock types are supported.
You should try opening a default cursor to see if that works.

If there was a problem with the sql statement, you would have gotten a
syntax error, or something like that.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2
Hi,

Thanks, indeed i leave it to a default cursor and now i get this:

Microsoft][ODBC Excel Driver] Undefined function 'REPLACE' in expression.

Adrian


Bob Barrows [MVP] wrote:
adrian zaharia wrote:
Hello,

Is it possible to use Replace function in a query against an
excel file?

I am trying this test code and gives me an error:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath('file.xls') & ";" &
"DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstCmd = "SELECT REPLACE('abc', 'a', 'x') AS X"
rstExcel.Open rstCmd, cnnExcel, adOpenStatic, adLockPessimistic
Response.Write rstExcel("X")
Response.End

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/search/default.asp, line 26

Is there a driver limitation or is something i do wrong?

Thanks

Adrian Zaharia


This error message is referring to the cursor and locktypes you chose. It
obviously cannot support a static cursor with pessimistic locking. I've
never used this so I don't know what cursor and lock types are supported.
You should try opening a default cursor to see if that works.

If there was a problem with the sql statement, you would have gotten a
syntax error, or something like that.

Bob Barrows


Jul 22 '05 #3
Which means exactly what it says. You'll have to do the replacement in your
vbscript code before displaying the data.

Bob Barrows

adrian zaharia wrote:
Hi,

Thanks, indeed i leave it to a default cursor and now i get this:

Microsoft][ODBC Excel Driver] Undefined function 'REPLACE' in
expression.

Adrian


Bob Barrows [MVP] wrote:
adrian zaharia wrote:
Hello,

Is it possible to use Replace function in a query against an
excel file?

I am trying this test code and gives me an error:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath('file.xls') & ";" &
"DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstCmd = "SELECT REPLACE('abc', 'a', 'x') AS X"
rstExcel.Open rstCmd, cnnExcel, adOpenStatic, adLockPessimistic
Response.Write rstExcel("X")
Response.End

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/search/default.asp, line 26

Is there a driver limitation or is something i do wrong?

Thanks

Adrian Zaharia


This error message is referring to the cursor and locktypes you
chose. It obviously cannot support a static cursor with pessimistic
locking. I've never used this so I don't know what cursor and lock
types are supported. You should try opening a default cursor to see
if that works.

If there was a problem with the sql statement, you would have
gotten a syntax error, or something like that.

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #4
Great,

the only *tiny* problem is that finally i need to do a

select ... where replace(...) = 'value'

so vb will not help me here :(

thanks anyway even if i did not found if indeed i cannot use replace or
there is a workaround...

Adrian


Bob Barrows [MVP] wrote:
Which means exactly what it says. You'll have to do the replacement in
your vbscript code before displaying the data.

Bob Barrows

adrian zaharia wrote:
Hi,

Thanks, indeed i leave it to a default cursor and now i get this:

Microsoft][ODBC Excel Driver] Undefined function 'REPLACE' in
expression.

Adrian


Bob Barrows [MVP] wrote:
adrian zaharia wrote:
Hello,

Is it possible to use Replace function in a query against an
excel file?

I am trying this test code and gives me an error:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath('file.xls') & ";" &
"DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstCmd = "SELECT REPLACE('abc', 'a', 'x') AS X"
rstExcel.Open rstCmd, cnnExcel, adOpenStatic, adLockPessimistic
Response.Write rstExcel("X")
Response.End

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/search/default.asp, line 26

Is there a driver limitation or is something i do wrong?

Thanks

Adrian Zaharia

This error message is referring to the cursor and locktypes you
chose. It obviously cannot support a static cursor with pessimistic
locking. I've never used this so I don't know what cursor and lock
types are supported. You should try opening a default cursor to see
if that works.

If there was a problem with the sql statement, you would have
gotten a syntax error, or something like that.

Bob Barrows


Jul 22 '05 #5
"adrian zaharia" <ad****@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Great,

the only *tiny* problem is that finally i need to do a

select ... where replace(...) = 'value'

so vb will not help me here :(

thanks anyway even if i did not found if indeed i cannot use replace or
there is a workaround...


Can you describe the replace you need to perform? Perhaps there's a LIKE
expression that would suit your needs.
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Marcum | last post by:
I need to write a query in Access that returns the results of a text field with the spaces replaced with underscores. So, if the data in the field was 'hello world', the query results would show...
15
by: daniroy | last post by:
Hello everybody, your help will be very very welcome on a very classic question... I have some Excell Macro background, a little bit of VBA knowledge. I import daily from Internet series of...
9
by: Anthony | last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't really changed since the days of VB6. That is, I'd do something similar to this Code: Dim ExcelApp As...
5
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
0
by: DrewYK | last post by:
I have the project that may never end in front of me. I am creating a routine that will take SpreadSheets from Excel and bring them into Access. I am not using any "DoCmd"s because the goal...
2
by: Dhananjay | last post by:
Hi all , I have got problem when i am tring to exportGridview Data into Excel format. It is going into text format ,but what i want is if the field is number/currency then it should go into...
1
by: JRussell | last post by:
Hi, I am trying to download sql database through asp on my webpage and I keep getting weird outcomes in Excel. I have had to put in <char10> and <char13> into my sql data to have it display...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
1
by: chandhseke | last post by:
Hi folks, I am a newbie to this functionality of creating excel report using VB/VB Script. I have been given a code and asked to add filters to the excel sheet that is created using the below...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.