.NETGURU
odbc command not returning results
Messages   Related Types
This message was discovered on microsoft.public.dotnet.distributed_apps.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

impulse24 via .Net Guru (VIP)
(Type your message here)

--------------------------------
From: Impulse24

system.Odbc vs system.sqlclient

I have created an app that is calling a stored procedure in Sql server. It works fine if I use the system.sqlclient namespace. I have to be able to use the system.odbc namespace so that my client can use an odbc dsn. Once I change from sqlCommand to odbcCommand I dont get any errors when I do odbcCommand.ExecuteNonQuery, but no data is returned. If I change the command to sqlCommand. .ExecuteNonQuery I get results. Below is my sample code:

myConnection = New OdbcConnection("DSN=schoolrec")
myConnection.Open()

myCommand = New OdbcCommand
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "spSelectSchool"
myCommand.Parameters.Add("@iSchoolID", OdbcType.Int)
myCommand.Parameters("@iSchoolId").Value = 2500
myCommand.Parameters.Add("@sSchoolName", OdbcType.Char)
myCommand.Parameters("@sSchoolName").Direction = ParameterDirection.Output
myCommand.ExecuteNonQuery()
Console.WriteLine(myCommand.Parameters("@sSchoolName").Value)

If I just change from odbc to sql it works. Is there something I have to do differently for odbc vs sql. Please help

-----------------------
Posted by a user from .Net Guru (http://www.dot-net-guru.com/)

<Id>GYkgc6X/rE+htTOW2rnaSQ==</Id>
Reply to this message...
 
    
Sam Santiago
Have you turned on SQL Profiler to determine that the stored procedure is
actually getting invoked? Also, if you look at this example it uses the
odbc call syntax to invoke a stored procedure. Note the curly bracket, CALL
keyword, and '?' for each parameter:

How To Execute SQL Parameterized Stored Procedures by Using the ODBC .NET
Provider and Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;309486

An excerpt from this link:

"Here is an example of the call syntax for a stored procedure that expects
one input parameter and returns one output parameter and a return value. The
first placeholder represents the return value:
{? = CALL Procedure1 (?, ?)"Thanks,

Sam
--
_______________________________
Sam Santiago
Click here to reveal e-mail address
http://www.SoftiTechture.com
_______________________________
"impulse24 via .Net Guru" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
(Type your message here)

--------------------------------
From: Impulse24

system.Odbc vs system.sqlclient

I have created an app that is calling a stored procedure in Sql server. It
works fine if I use the system.sqlclient namespace. I have to be able to
use the system.odbc namespace so that my client can use an odbc dsn. Once I
change from sqlCommand to odbcCommand I dont get any errors when I do
odbcCommand.ExecuteNonQuery, but no data is returned. If I change the
command to sqlCommand. .ExecuteNonQuery I get results. Below is my sample
code:

myConnection = New OdbcConnection("DSN=schoolrec")
myConnection.Open()

myCommand = New OdbcCommand
myCommand.Connection = myConnection
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "spSelectSchool"
myCommand.Parameters.Add("@iSchoolID", OdbcType.Int)
myCommand.Parameters("@iSchoolId").Value = 2500
myCommand.Parameters.Add("@sSchoolName", OdbcType.Char)
myCommand.Parameters("@sSchoolName").Direction =
ParameterDirection.Output
myCommand.ExecuteNonQuery()
Console.WriteLine(myCommand.Parameters("@sSchoolName").Value)

If I just change from odbc to sql it works. Is there something I have to do
differently for odbc vs sql. Please help

-----------------------
Posted by a user from .Net Guru (http://www.dot-net-guru.com/)

<Id>GYkgc6X/rE+htTOW2rnaSQ==</Id>

Reply to this message...
 
 
System.Console
System.Data.CommandType
System.Data.Odbc.OdbcCommand
System.Data.Odbc.OdbcConnection
System.Data.Odbc.OdbcType
System.Data.ParameterDirection




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification