[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

STored Procedure with Parameters

Jasim Iqbal

3/6/2002 12:10:00 AM

hi all,

i have a small problem with my stored procedure, my
connection is correct and my stored procedure also works
fine while working in simple ASP (not ASP.NET).

now my problem is i have to pass two parameters
named 'sid_1' and 'sid_2' when calling stored
procedure ....

i am writting my code below, can someone correct it if u
know where problem could be ... i believe i'm not making
the parameters correct.(values of parameters should be
sid_1 = 4, sid_2 = 5)

******************************************
SqlConnection newmyConnection = new SqlConnection("user
id=sa;password=sa;server=challenge360;Trusted_Connection=no
;databaseºckTest");
SqlCommand myCommand2 = new
SqlCommand ();
myCommand2.Connection =
newmyConnection;
myCommand2.CommandText
= "spGetRouteInfo";
myCommand2.CommandType =
CommandType.StoredProcedure;
newmyConnection.Open();
SqlDataReader myReader2;
myCommand2.Parameters.Add
("@sid_1", SqlDbType.Decimal , 18, s1);
myCommand2.Parameters.Add
("@sid_2", SqlDbType.Decimal , 18, s2);
myReader2 =
myCommand2.ExecuteReader();

while (myReader2.Read())
{
for (int i=0;
i<myReader2.FieldCount; i++)
{
string dt;
dt =
myReader2.GetDataTypeName(i);
dt =
myReader2.GetName(i);
lst1.Items.Add
(dt);
lst1.Items.Add
(myReader2.GetDecimal(i).ToString());
}//end for
Console.WriteLine();
}//end while

// always call Close when done
reading.
myReader2.Close();

Console.WriteLine("The Values are
Shown!");
// Close the connection when done
with it.
newmyConnection.Close();