Help Please -- ADODB.Command does not work correctly in .NET

Help Please -- ADODB.Command does not work correctly in .NET

Post by Iva » Fri, 20 Feb 2004 07:59:52



Hi all,
i have been trying this for 7 hrs now !!!

How do you call a adodb.command object in  .net(c#)

code******
ADODB.Connection cn = new ADODB.ConnectionClass();
ADODB.Command cm = new ADODB.CommandClass();
ADODB.Parameter pa = new ADODB.ParameterClass();
ADODB.Recordset rs = new ADODB.RecordsetClass();
object rc;

cn.Provider="SQLOLEDB.1";
cn.Open(ConfigurationSettings.AppSettings["sqlServerConnection"].ToString(),"","",-1);

cm.ActiveConnection=cn;
cm.CommandType=ADODB.CommandTypeEnum.adCmdStoredProc;
cm.CommandText="sp_rptRegister";

ectionEnum.adParamInput,0,506);
cm.Parameters.Append(pa);

object par= cm.Parameters;

rs=cm.Execute(out rc,ref
par,(int)ADODB.CommandTypeEnum.adCmdStoredProc);

sXML=rs.Fields[0].Value.ToString();  

code******

The last line gives an error that it is BOF AND EOF (when there are
records!)
(it give the field names but not the records, i suspect the parameter
value is not getting passed to the sp (and yes i have tried passing
the value pa[0].value=506 in a seperate statement))

I have tried using the CommandText="sp_rptRegister 506" and it works
but i need to use the para collection.

Please Please somebody help me.....i need a solution by tonite

Thanks in advance

Ivan

 
 
 

Help Please -- ADODB.Command does not work correctly in .NET

Post by oj » Fri, 20 Feb 2004 10:06:07


Be sure to put 'set nocount on' as the first statement in your stored procedure.
This prevents 'DONE_IN_PROC' messages from returning as an empty recordset.

Also, you're working with .NET why not use ADO.NET, specifically
System.Data.SqlClient namespace.
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataSql...

--
-oj
http://www.rac4sql.net


Quote:> Hi all,
> i have been trying this for 7 hrs now !!!

> How do you call a adodb.command object in  .net(c#)

> code******
> ADODB.Connection cn = new ADODB.ConnectionClass();
> ADODB.Command cm = new ADODB.CommandClass();
> ADODB.Parameter pa = new ADODB.ParameterClass();
> ADODB.Recordset rs = new ADODB.RecordsetClass();
> object rc;

> cn.Provider="SQLOLEDB.1";

cn.Open(ConfigurationSettings.AppSettings["sqlServerConnection"].ToString(),"","
",-1);
Quote:

> cm.ActiveConnection=cn;
> cm.CommandType=ADODB.CommandTypeEnum.adCmdStoredProc;
> cm.CommandText="sp_rptRegister";

ectio
nEnum.adParamInput,0,506);
Quote:> cm.Parameters.Append(pa);

> object par= cm.Parameters;

> rs=cm.Execute(out rc,ref
> par,(int)ADODB.CommandTypeEnum.adCmdStoredProc);

> sXML=rs.Fields[0].Value.ToString();

> code******

> The last line gives an error that it is BOF AND EOF (when there are
> records!)
> (it give the field names but not the records, i suspect the parameter
> value is not getting passed to the sp (and yes i have tried passing
> the value pa[0].value=506 in a seperate statement))

> I have tried using the CommandText="sp_rptRegister 506" and it works
> but i need to use the para collection.

> Please Please somebody help me.....i need a solution by tonite

> Thanks in advance

> Ivan


 
 
 

Help Please -- ADODB.Command does not work correctly in .NET

Post by Val Mazu » Sat, 21 Feb 2004 05:58:59


Hi Ivan,

I think OJ is right. SET NOCOUNT could help and he is also right that there
is no reason to use COM-based ADO in .NET applications. Use ADO.NET instead.

--
Val Mazur
Microsoft MVP


> Hi all,
> i have been trying this for 7 hrs now !!!

> How do you call a adodb.command object in  .net(c#)

> code******
> ADODB.Connection cn = new ADODB.ConnectionClass();
> ADODB.Command cm = new ADODB.CommandClass();
> ADODB.Parameter pa = new ADODB.ParameterClass();
> ADODB.Recordset rs = new ADODB.RecordsetClass();
> object rc;

> cn.Provider="SQLOLEDB.1";
> cn.Open(ConfigurationSettings.AppSettings["sqlServerConnection"].ToString(),"","",-1);

> cm.ActiveConnection=cn;
> cm.CommandType=ADODB.CommandTypeEnum.adCmdStoredProc;
> cm.CommandText="sp_rptRegister";

ectionEnum.adParamInput,0,506);
> cm.Parameters.Append(pa);

> object par= cm.Parameters;

> rs=cm.Execute(out rc,ref
> par,(int)ADODB.CommandTypeEnum.adCmdStoredProc);

> sXML=rs.Fields[0].Value.ToString();

> code******

> The last line gives an error that it is BOF AND EOF (when there are
> records!)
> (it give the field names but not the records, i suspect the parameter
> value is not getting passed to the sp (and yes i have tried passing
> the value pa[0].value=506 in a seperate statement))

> I have tried using the CommandText="sp_rptRegister 506" and it works
> but i need to use the para collection.

> Please Please somebody help me.....i need a solution by tonite

> Thanks in advance

> Ivan

 
 
 

1. Net Assistant test ok, but command line login does not WORK

Net Assistant test ok, but command line login does not
work.  connectivity problems

hi, gurus,

I could install ora817 client on win2000 pro. Using
Net8 assistant, I could setupa servicing name, and
test it just ok.

however, it does not work on command line: sqlplus

resolve service name.

and also sqlplus will not connect to the servrer,
using scott/tiger, host_string: o3. the same error
message.

The related 2 .ora files are print in part for
refereces.

please offer your suggestions and any hints.  thanks
in advance.

tnsnames.ora --------------
O3 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST =
goldfinger)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = o3)
    )
  )

sqlnet.ora-----------------------------------
#SQLNET.ORA Network Configuration File:
C:\oracle\ora81\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

2. PDOX 7.0 Runtime Errors

3. SELECT...WHERE EmployeeID NOT IN (...) not working correctly

4. SELECT Desperate and Agonized OUT OF MOI....

5. Err in using ADODB Command Object in VB.Net

6. DB-Library network communications layer not loaded

7. Problems with com adodb.command in vb.net

8. US-Oracle DBA/ Financials/ Manufacturing-Technical or Functional

9. TCL sh command dosen't work correctly

10. SQL Server DMO Backup Object Events Not Firing Correctly with Visual Basic .NET

11. isqlw command not formatting text correctly

12. ADODB.Command Execute() doesn't work from JScript with XPath query dialect