0

I have a .Net dll which provides me exposed function RunSqlQuery(). This function returns System.Data.Dataset. I am calling this function from VBScript.

If I use the C# syntax of dataset in VBScript, I get error "Object required"

How can I get the data from the dataset in VBScript?

.NET Dll function signature:

public DataSet RunSqlQuery(string query); 

My VBScript code:

On Error Resume Next Dim objSQLDB Dim dataset Dim retVal set objSQLDB = CreateObject("SQLManagement.SQLServer") retVal = objSQLDB.Connect("server-address", "username", "password") If retVal = 0 Then WScript.echo "Failed to connect: " & Err.Number & " " & Err.Description WScript.Quit End If 'Any of the below two lines does not help resolving Object required error dataset = objSQLDB.RunSqlQuery("Select 1") 'set dataset = objSQLDB.RunSqlQuery("Select 1") If Err.Number <> 0 Then WScript.echo "Error running query: " & Err.Number & " " & Err.Description WScript.Quit End If ' Stuck here : how to extract data from the dataset ' Below two lines does not work ' Error message: Microsoft VBScript runtime error: Object required WScript.echo dataset.Tables.Count WScript.echo dataset.Tables[0].Rows.Count objSQLDB.Disconnect objSQLDB = Nothing 
11
  • @JSteward How? The link you provided is about connecting to database from VBScript through ADO. After that the records are fetched through ADODB.Recordset. Here in my case it is a .Net System.Data.Dataset. Do you mean to say they are same? I do not think so. Educate me if I am wrong. Commented Sep 18, 2019 at 18:16
  • Looks like my mistake, retracted, thought they were working with datasets as well. Commented Sep 18, 2019 at 18:20
  • Possible duplicate of Calling C# dll in vbscript Commented Sep 18, 2019 at 22:25
  • @Lankymart no it is not. My question is not about calling a dll and returning any value, but particular to System.data.dataset. I am stuck at how to extract data from a dataset after the dll returns the dataset . Commented Sep 19, 2019 at 3:19
  • What have you tried, just showing a comment in code saying Stuck here: with no actual attempt isn't very helpful. Have you actual tried to call some methods or properties of the DataSet object? Did you encounter an error when you tried? Can you show your attempts? Commented Sep 19, 2019 at 7:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.