473,770 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using an OLE DB Provider's Functions in Code

Sometimes we use script or code whose variable types do not correspond to
the variable types of other technologies with which they interface.
It's possible that our db provider may come to our rescue, both by
applyling its functions and by "returning" a compatible dtat type.

Here is a VBA-ADO-MS-SQL example. It uses MS-SQL functions to trim a
string. (Yes, I know VBA has these functions; I am attempting to
demonstrate a capability, not to show an explicit solution for something. I
am experimenting with using this in dealing with the ASP Request.Form
object in javascript.)

Sub temp()
Dim s As String
s = " PaddedString "
Debug.Print Len(s) ' 16
s = CurrentProject. Connection.Exec ute( _
"SELECT TOP 1 LTRIM(RTRIM('" & s & "')) " _
& "FROM Schools").Colle ct(0)
Debug.Print Len(s) ' 12
End Sub
--
Lyle
--
Nov 13 '05 #1
3 1997
On Apr 02 2005, 07:11 pm, Lyle Fairfield <Lo******@FFDBA .Com> wrote in
news:Xn******** ***********@216 .221.81.119:
Sub temp()
Dim s As String
s = " PaddedString "
Debug.Print Len(s) ' 16
s = CurrentProject. Connection.Exec ute( _
"SELECT TOP 1 LTRIM(RTRIM('" & s & "')) " _
& "FROM Schools").Colle ct(0)
Debug.Print Len(s) ' 12
End Sub


A Sunday morning nitpick: You don't need the FROM clause in there.

You mention using the data provider to "return" a compatible data type. I
don't think this is demonstrated in your example, and I'm not sure I know
exactly how you would do this. Another example, perhaps?

--
remove a 9 to reply by email
Nov 13 '05 #2
Dimitri Furman <df*****@cloud9 9.net> wrote in
news:Xn******** *************** *****@127.0.0.1 :
On Apr 02 2005, 07:11 pm, Lyle Fairfield <Lo******@FFDBA .Com> wrote in
news:Xn******** ***********@216 .221.81.119:
Sub temp()
Dim s As String
s = " PaddedString "
Debug.Print Len(s) ' 16
s = CurrentProject. Connection.Exec ute( _
"SELECT TOP 1 LTRIM(RTRIM('" & s & "')) " _
& "FROM Schools").Colle ct(0)
Debug.Print Len(s) ' 12
End Sub


A Sunday morning nitpick: You don't need the FROM clause in there.

You mention using the data provider to "return" a compatible data type. I
don't think this is demonstrated in your example, and I'm not sure I know
exactly how you would do this. Another example, perhaps?


Yes, and when you don't use the FROM the TOP 1 is redundant as well. Thank
you.

This is some trivial ASP-Javascript stuff.

a form

<form method="post" action="copy of classes.asp" >
<input type ="text" value =" Dimitri "
<input type="submit">
</form>

some asp-javascript in copy of classes.asp

var s=Request.Form;
Response.Write( '<p>'+typeof s+'</p>');
Response.Write( '<p>'+s.constru ctor+'</p>');
Response.Write( '<p>'+s+':'+s.l ength+'</p>');
s=c.Execute('SE LECT LTRIM(RTRIM(\'' +s+'\'))').Coll ect(0);
Response.Write( '<p>'+typeof s+'</p>');
Response.Write( '<p>'+s.constru ctor+'</p>');
Response.Write( '<p>'+s+':'+s.l ength+'</p>');

which yields:

object
undefined
:undefined
string
function String() { [native code] }
:0

it seems we have to convert Request.Form to a string before we can deal
with it in some ways, such a trimming it; the sql call is one way; so is
var s=new String(Request. Form); s=s.toString() is not as it produces an
error on my server.

So the sql is not required here but as it seems MS is committed to VB like
scripts and data structures there may be some situation where it will be
the only way I can find.

Did you know ADO GetRows returns a VBArray type which must? be converted
with toArray when used in Jscript? In a non-MS technology I expect one
would have to something heroic to make this conversion, if GetRows is
available at all. To be safer I have been using GetString and Splits. The
resulting array may have a more untuitive structure; that is element [5][2]
corresponds to record 6 field 3 rather than record 3 field 6.

I digress ...
--
Lyle
--
Nov 13 '05 #3
On Apr 03 2005, 05:49 pm, Lyle Fairfield <Lo******@FFDBA .Com> wrote in
news:Xn******** ***********@216 .221.81.119:
This is some trivial ASP-Javascript stuff.

a form

<form method="post" action="copy of classes.asp" >
<input type ="text" value =" Dimitri "
<input type="submit">
</form>

some asp-javascript in copy of classes.asp

var s=Request.Form;
Response.Write( '<p>'+typeof s+'</p>');
Response.Write( '<p>'+s.constru ctor+'</p>');
Response.Write( '<p>'+s+':'+s.l ength+'</p>');
s=c.Execute('SE LECT LTRIM(RTRIM(\'' +s+'\'))').Coll ect(0);
Response.Write( '<p>'+typeof s+'</p>');
Response.Write( '<p>'+s.constru ctor+'</p>');
Response.Write( '<p>'+s+':'+s.l ength+'</p>');

which yields:

object
undefined
:undefined
string
function String() { [native code] }
:0

it seems we have to convert Request.Form to a string before we can
deal with it in some ways, such a trimming it; the sql call is one
way; so is var s=new String(Request. Form); s=s.toString() is not as it
produces an error on my server.

So the sql is not required here but as it seems MS is committed to VB
like scripts and data structures there may be some situation where it
will be the only way I can find.


Not having any ASP or javascript, I can't be sure that I understand this
properly; I think I see your point, but cannot come up with a VB/VBA
scenario that would require this, other than the obvious one of using some
"foreign" functions not available in VB/VBA. Apparently this technique can
be useful in ASP-javascript - it may be also helpful if you show how this
can benefit VB/VBA code.

--
remove a 9 to reply by email
Nov 13 '05 #4

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

Similar topics

1
11590
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like Account Additional, Sale_Additional so most tables stay the same. The latest restored database (I'll call it DBaseA) is behaving differently in VB6 code and I need help trying to make it work. I have been using use an ADODB.Command to execute...
0
6703
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
1
6434
by: Roland Bengtsson | last post by:
I have an application that I want to use an embedded database in. I started with MySQL and ODBC (client server model) but want to change that. I found SQLite http://www.sqlite.org and found it promising, a single dll-file contains all the needed functions. I'm new to C# but I found that I have to write C# functions marked with unsafe keyword do call an external dll-file. I tried to add an reference to sqlite.dll in Visual .NET 2003 but I...
8
2581
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
2
8658
by: Tim Frawley | last post by:
I am attempting to change the ODBC Link Provider String in an Access database linked to an Oracle server using ADOX in VB.NET. I created some code using the example from post: http://groups.google.com/groups?q=RefreshLinkedTablesWithADOX()&hl=en&lr=&selm=qb1ctvcdoftenojhpp34lb6fjb9ss8qd9c%404ax.com&rnum=1 My code simply replaces the DSN, UID, PWD and DBQ values in the ADOXTable.Properties("Jet OLEDB:Link Provider String").Value string...
3
5084
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling our web service (The "Web Service Server") running on a separate machine (also .NET 2.0, Win2003 Server, system 2). The web service server (system 2) itself makes calls to methods in the CRM
7
7745
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee free edition for anti-virus. I use an ISP provider from my country and according to them I do not need to perform authentication while sending mails through their SMTP address. Thus I am using external SMTP server. I don't have IIS installed...
6
5769
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
0
952
by: askcoffman | last post by:
I have a login control that is used as a template for all of my websites. I am trying to integrate my Custom Membership provider, but cannot create a provider object to access the functions, specifically validate user( ). How can I use my own login control and combine the provider functions?
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.