For the parameter name I recommend verufying it with enterprise manager.

First of all every page you make should not be getting stack traces /
Yellow Screen of Death (YSOD). Add Try, Catch, Finally and proper
minimal error trapping so future runtime errors do not appear so
severe.

http://www.learnasp.com/freebook/learn/cs_dbtable.aspx
(C#)

http://www.learnasp.com/freebook/learn/dbopen.aspx
(VB.net)

shows the basic structure of TRY/CATCH/FINALLY and good connection
closing best practices as well.

You also should not be returning DATASETS you should be returning
DataTables. DataTables are 10 x lighter. Make a function so you always
do this in a resuable way something like....

protected DataTable DataTableMaker(string strConn, string strSQL) 
        {
        dt1= new DataTable("temp");
        conn=new SqlConnection(strConn);
        adapter=new SqlDataAdapter(strSQL, conn);
        Return(Adapter.Fill(dt1))
        }


On Mon, 24 Jan 2005 18:54:07 -0000, scaevola637 <[EMAIL PROTECTED]> wrote:
>  
>  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 Versio


 
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/
 



Reply via email to