473,388 Members | 1,177 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,388 software developers and data experts.

VBScript To VB.NET Recodset question.

I am trying to execute VBScript functions via MSScriptControl in
VB.NET and have the function return a ADODB Recordset. rs3 in the
example below is returned as type __ComObject. I tried using
Marshal.CreateWrapperTypeOf to create a COM wrapper. Anyone have any
ideas how I can I access the recordset back in vb.net, I am able to
get a fields value back from the function. I am interested in using
the RS -- Such As: Dim rs as new ADODB.Recordset = rs3 .

Thanks
Ron

----- Code Snippet ------
Dim sc As New MSScriptControl.ScriptControl()
sc.Language = "VBScript"
sc.AddCode("Function xcv()" & vbCrLf & "SET db =
CreateObject(""ADODB.Connection"")" & vbCrLf &
"db.Open(""PROVIDER=SQLOLEDB;UID=psafe_user;PWD=ps afe_user;SERVER=IKE;DATABASE=psafe2;"")"
& vbCrLf & "set rs2 = db.execute(""select * from issue"")" & vbCrLf &
"xcv=rs2" & vbCrLf & "End Function")

Dim ex As String = "xcv"
Dim rs3 As New Object()

rs3 = sc.Eval(ex)
Nov 20 '05 #1
3 2196
"Ron Pagliuca" <ro*********@hotmail.com> schrieb
I am trying to execute VBScript functions via MSScriptControl in
VB.NET and have the function return a ADODB Recordset. rs3 in the
example below is returned as type __ComObject. I tried using
Marshal.CreateWrapperTypeOf to create a COM wrapper. Anyone have
any ideas how I can I access the recordset back in vb.net, I am able
to get a fields value back from the function. I am interested in
using the RS -- Such As: Dim rs as new ADODB.Recordset = rs3 .

Thanks
Ron

----- Code Snippet ------
Dim sc As New MSScriptControl.ScriptControl()
sc.Language = "VBScript"
sc.AddCode("Function xcv()" & vbCrLf & "SET db =
CreateObject(""ADODB.Connection"")" & vbCrLf &
"db.Open(""PROVIDER=SQLOLEDB;UID=psafe_user;PWD=ps afe_user;SERVER=IKE;DATABA
SE=psafe2;"")" & vbCrLf & "set rs2 = db.execute(""select * from issue"")" & vbCrLf
& "xcv=rs2" & vbCrLf & "End Function")

Dim ex As String = "xcv"
Dim rs3 As New Object()

rs3 = sc.Eval(ex)

After setting a reference to the ADODB COM library, does

Dim rs as ADODB.Recordset
rs = directcast(rs3, adodb.recordset)

work?

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

DIRECTCAST did not work error message is "SPECIFIED CAST IS NOT VALID".
I also tried CTYPE similar results too. Any other suggestions would be
helpful. The VBscript is executing, because I can return a STRING from
it. I have a COM reference in VS.NET in my VB.NET project to ADODB as
well. Please help me out, I truly appreciate it.

Ron
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
I am not sure if my reply posted as I do not see it anywhere. DIRECT
CAST did not work, it gave a "SPECIFIED CAST NOT VALID". I did make the
ADODB COM reference as well then executed my code. Any further
assistance would be welcomed... Oh dire straits...

Thanks Again,

Ron

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4

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

Similar topics

8
by: Dave Thomas | last post by:
I have developed a web site using asp pages that use both vbscript and javascript. Run the site on my PC and everything is fine. Ftp to my web hosting provider which hosts asp pages and look on my...
3
by: Dana | last post by:
I have a form with a couple of dropdown fields. the dropdown fields get the value from one table which is a reference table. The table consists of 3 columns - type, id, name. An example would...
5
by: Leszek | last post by:
Hello gurus! I wrote a code in VBS, that will check, that current user is in one from three groups. But i don't know how asimilate it with asp.net. This page will be a bridge between 2 - main...
1
by: Ian Sedwell | last post by:
Hi guys Many thanks to all who replied to my original question. Actually, it's dead easy and the way I was doing it was correct the first time. You do indeed simply call the VBScript routine...
3
by: Mark Fox | last post by:
Hello, I am porting some old ASP 3.0 VBScript code to C#.NET and am not sure what the equivalent C# functions are for a couple VBScript functions. So my first question is: 1) Is there...
4
by: sparky | last post by:
I've been working on an ASP driven website, on a client's web hosting space. One of the project requirements was the ability for the client to be able to upload files through an HTTP form. No...
0
by: thisis | last post by:
Hi All, I'm getting an error on my ASP page: Microsoft VBScript runtime error '800a000d' Type mismatch: 'StoreFileIntoField' I assume - 99.5% - the error is generated because of worng...
2
by: tunk | last post by:
I dont know where to start my question so let me tell you my story :) The ASP that cause me trouble is running on IIS that set ASP default language to JScript instead of VBScript. This ASP page...
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.