Link to home
Start Free TrialLog in
Avatar of GoldenJag
GoldenJag

asked on

SQL Connection using CommandType.StoredProcedure and SQLDataAdapter

I am new to .NET so any advice is welcomed.  Can someone tell me what i am doing wrong in this segment of code.

I am trying to run a Crystal Report and I have defined a Dataset1.xsd in my project.  I am not sure if i am doing the comd.Connection correctly. but i get an error (on line  "da.Fill(ds);  " that says:

Can someone help me with this.

{"Load report failed." }
    System.Object: {System.Exception}
    _className: null
    _COMPlusExceptionCode: -532459699
    _exceptionMethod: <undefined value>
    _exceptionMethodString: null
    _helpURL: null
    _HResult: -2146233088
    _innerException: {"Not enough memory for operation." }
SqlConnection sqlConn = new SqlConnection(pm.connection);
                  
                  SqlCommand comd=sqlConn.CreateCommand();  //??

                  comd = new SqlCommand();
                  comd.Connection = sqlConn;
                  comd.CommandType = CommandType.StoredProcedure;
                  comd.CommandText = "sp_Test";
                  //comd.Parameters.Add("@ProgID",SqlDbType.VarChar,50);
                  sqlConn.Open();
                  SqlDataAdapter da = new SqlDataAdapter(comd);

                  //TEST
                  try
                  {
                        Dataset1 ds = new Dataset1();
                        da.Fill(ds);   //ERRORS HERE
                        oRpt.SetDataSource(ds);
                        CrystalReportViewer1.ReportSource = oRpt;
                  }
                  catch(Exception ex)
                  {
                        Response.Write(ex.Message.ToString());
                  }



Thanks!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

sqlConn.Open();
SqlCommand comd=sqlConn.CreateCommand("sp_Test");  //??
comd.CommandType = CommandType.StoredProcedure;
//comd.Parameters.Add("@ProgID",SqlDbType.VarChar,50);
SqlDataAdapter da = new SqlDataAdapter(comd);

ASKER CERTIFIED SOLUTION
Avatar of AGBrown
AGBrown
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GoldenJag
GoldenJag

ASKER

I am using MS C# Development Environment 2003 version 7.1.3088 (Visual Studio 6.0)
MS.Net Framework 1.1 version 4322 SP1, Crystal XI.

The program errors here:   da.Fill(ds);   //ERRORS HERE
the error also occurs when i use da.Fill(ds,"TableName");



I am sorry guys. i gave you wrong info about where program errored.

It errored at : oRpt.SetDataSource(ds); and not at the da.Fill(ds).



This is definitely a Crystal problem then, I think there is a business objects hotfix for it, though I haven't come across this problem myself or had the need to test the hotfix.