No Results

J

Jim Heavey

Hello, I have looked at this and then looked at it somemore, but I can't
see anything wrong...

Here is my senario.
I wrote a stored procedure to return information about the parms in a
stored procedure. The idea being is that I will build all my Parameters
for any stored procedure mechanically.
I run this procedure in Query Analyzer and it runs fine
I run the procedure in VS.Net as a stand alone proc and it runs just
fine (says it returned 2 rows).
I run the same procedure in a C# program, and it executes but no results
ever comeback. I get a return code of 0, but no results.

I put some code in and wrote all all the parm names and their values in
the debug window, cut and pasted those values into Query Analyzer and
ran those exact same parm names and values - and it ran fine - bringing
back results. The only difference is that there were two parms in which
I loaded "DBNull.Value" and I had to type "null" in query analzer.

I have tried using a DataReader and a DataAdapter with each running
successfully, but still no rows.

How in the world could it run everywhere else other in my c# code?

Here is some code...

Set up my parms...
cmd.Parameters.Add("@procedure_name",SqlDbType.NVarChar,390).Direction =
ParameterDirection.Input;
cmd.Parameters["@procedure_name"].Value= ProcName;

cmd.Parameters.Add("@procedure_owner",SqlDbType.NChar,384).Direction =
ParameterDirection.Input;
cmd.Parameters["@procedure_owner"].Value=dbOwner;

cmd.Parameters.Add("@procedure_qualifier",SqlDbType.NChar,384).Direction
= ParameterDirection.Input;
cmd.Parameters["@procedure_qualifier"].Value=dbName;

cmd.Parameters.Add("@column_name",SqlDbType.NChar,384).Direction =
ParameterDirection.Input;
cmd.Parameters["@column_name"].Value=DBNull.Value ;

cmd.Parameters.Add("@ODBCVer",SqlDbType.Int,2).Direction =
ParameterDirection.Input;
cmd.Parameters["@ODBCVer"].Value=System.DBNull.Value ;

cmd.Parameters.Add("@RETURN_VALUE",SqlDbType.Int).Direction =
ParameterDirection.ReturnValue ;

My Command...

cmd = new SqlCommand();
cmd.CommandText= dbName + "." + dbOwner + "." + ProcName;
cmd.CommandType = CommandType.StoredProcedure;

My Open
cmd.Connection.Open();

The DataReader
SqlDataReader dr = cmd.ExecuteReader();

The Read...
while (dr.Read())
{
Do Somthing - never get in here
}

Any Ideas?
 
W

William Ryan

I"m not sure from your code, but you could use profiler and see what's going
on back there... Or the lazy way, compile your VB.NEt code into a Class
library and add the reference to you C# project. I suspect something is
different though, that would be one really weird bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top