-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Sitaraman
Message 3 in Discussion
Hi Pandu, that wont work. will give u these errors 'object' does not contain a
definition for 'Commands'
'object' does not contain a definition for 'InitDomain'
'object' does not contain a definition for 'ParseRequest' Satish - u need to
understand that VB supports late binding so it is easy to declare a object type and
call methods and make them bind at runtime. In fact even in VB(VB.Net), you should
not use late bind as it has a performance overhead. Anyways the following is the code
in C# and VB(if u plan to use VB for this use early binding as below) both of them
using early binding. However to get the "Response Object from the parseRequest" and
"sql property from the command object" i needed to use reflection. it is as follows.
For this to work, add a reference to the Microsoft English Query Type Library 2.0
(available in the List of the COM tab of the Add References Dialog box) C# public
String GetNlSqlQueryCSharp(String nlEngQuery)
{
//Add Reference to Microsoft English Query Type Library 2.0 for this fn to work
Mseq.SessionClass msEqSession ;
Mseq.Response msEqResponse;
Mseq.Commands l_objCommands;
Mseq.Command l_objCommand;
//create object
msEqSession = new Mseq.SessionClass(); //initialize the file
msEqSession.InitDomain(strNlqDefinition);
//parse eng query and get Response Object
msEqResponse = msEqSession.ParseRequest(nlEngQuery); //Get the Commands From the
Response
l_objCommands =
(Mseq.Commands)msEqResponse.GetType().InvokeMember("Commands",BindingFlags.GetProperty,null,msEqResponse,null);
//Get the Command from the Commands
l_objCommand=l_objCommands.Index(0);
//Get the SQL Query from the Command Object
Object
l_strSQL=l_objCommand.GetType().InvokeMember("sql",BindingFlags.GetProperty,null,l_objCommand,null);
//return the SQL String
return l_strSQL.ToString();
}
VB.Net Public Function GetNlSqlQueryVBEarlyBind(ByVal nlEngQuery As String)
As String 'Add Reference to Microsoft English Query Type Library 2.0 for this
fn to work
Dim msEqSession As Mseq.Session
Dim msEqResponse As Mseq.Response 'create object
msEqSession = New Mseq.Session() 'initialize the file
msEqSession.InitDomain(strNlqDefinition)
'parse eng query and get commonds object
msEqResponse = msEqSession.ParseRequest(nlEngQuery)
'return sql query string
If msEqResponse.Type.ToString = "nlResponseCommand" Then
Return msEqResponse.Commands(0).sql.ToString
Else
Return "Problem in English Query"
End If End Function hope this helps regards, sr
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]