I am changing Database calls from vbscript to C# and the actual
classes from ado classes to ado.net classes. The calls are mainly
to sprocs in sql server 2000. Here is an example
<code>
ElseIf sLib = "C200" then
call OpenAFDLCR
cmdAFDLCR.CommandText = "GetDurableDoc"
Set dbParam = cmdAFDLCR.CreateParameter("@DocID", adVarChar,
adParamInput, 10, sDoc)
cmdAFCPT.Parameters.Append dbParam
Set rsDocument = cmdAFDLCR.Execute
sEDocID = rsDocument("DOCID")
Set rsDocument = Nothing
call CloseAFDLCR
sURL = "DLCR/searchdocument.asp?DocID=" & sEDocID
End If
</code>
here is my ado.net C#
<code>
else if(sLib == "C200")
{
SqlConnection myConnection = new SqlConnection
(ConfigurationSettings.AppSettings["connectionDLCR"]);
SqlDataAdapter myCommand = new SqlDataAdapter
("GetDurableDoc",myConnection);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterDocID = new SqlParameter
("@DOCID",SqlDbType.VarChar,10);
parameterDocID.Value = DocID;
myCommand.SelectCommand.Parameters.Add(parameterDocID);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet,"DOCID");
return myDataSet;
}
When I run this, I get this stack trace error message:
<message>
Server Error in '/Corporate' Application.
---------------------------------------------------------------------
-----------
@DocID is not a parameter for procedure GetDurableDoc.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: @DocID is not
a parameter for procedure GetDurableDoc.
Source Error:
Line 110:
myCommand.SelectCommand.Parameters.Add(parameterDocID);
Line 111: DataSet myDataSet = new
DataSet();
Line 112: myCommand.Fill
(myDataSet,"DOCID");
Line 113: return myDataSet;
Line 114: }
Source File: c:\inetpub\wwwroot\corporate\scripts\connectdc.cs
Line: 112
Stack Trace:
[SqlException: @DocID is not a parameter for procedure
GetDurableDoc.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior)
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader
(CommandBehavior behavior)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable)
Corporate.ConnectDC.GetDurableDoc(String sLib, String DocID) in
c:\inetpub\wwwroot\corporate\scripts\connectdc.cs:112
Corporate.Index.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\corporate\index.aspx.cs:55
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
---------------------------------------------------------------------
-----------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032
</message>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/