none
ExportToStream(ExportFormatType.PortableDocFormat) always giving error Details: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    Question

  • Hi i am always getting the following error while doing the following operation. i am sharing the code. please help

    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    namespace Convertor
    {
        public class Convertor
        {
                    
            public MemoryStream ConvertToStream(string sRPTFile, ArrayList alParameter)
            {
                MemoryStream oStream = null;
                ReportDocument doc = new ReportDocument();
                try
                {
                    doc.Load(sRPTFile);
                    // Add parameters
                    if (alParameter != null && alParameter.Count > 0)
                    {
                        for (int i = 0; i < alParameter.Count; i++)
                        {
                            doc.ParameterFields[i].CurrentValues.Clear();
                            doc.ParameterFields[i].CurrentValues.AddValue((int)alParameter[i]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < doc.ParameterFields.Count; i++)
                        {
                            doc.ParameterFields[i].CurrentValues.Clear();
                            doc.ParameterFields[i].CurrentValues.AddValue(System.DBNull.Value);
                        }
                    }
                }
                catch (Exception ex1)
                {
                    throw ex1;
                }
                try
                {
                    //Assign the database logon info
                    TableLogOnInfo logon = new TableLogOnInfo();
                    logon.ConnectionInfo.ServerName = "Server Name";                logon.ConnectionInfo.DatabaseName = "DataBaseName";
                    logon.ConnectionInfo.UserID = "User Id";
                    logon.ConnectionInfo.Password = "Password";
                    doc.Database.Tables[0].ApplyLogOnInfo(logon);
                }
                catch (Exception ex2)
                {
                    throw ex2;
                }
                try
                {
                    //export to memory stream.
                    oStream = (MemoryStream)doc.ExportToStream(ExportFormatType.PortableDocFormat);
                }
                catch (Exception ex3)
                {
                                    throw ex3;
                }
                finally
                {
                    if (doc != null) doc.Close();
                }
                return oStream;
            }
        }
    }

    This code always through error at Line : ExportToStream

    here is the stackstrace--

    System.Runtime.InteropServices.COMException (0x8004100F): Logon failed. Details: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Error in File C:\DOCUME~1\a512866\LOCALS~1\Temp\new {DACAE299-9B56-4E47-AAB1-1F8D8854B2EC}.rpt: Unable to connect: incorrect log on parameters. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext); at at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options) at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType) at FMRCo.EIMT.GMSReporting.Reporting.Convertor.ConvertToStream(String sRPTFile, ArrayList alParameter) in C:\EIMT_Views\a512866_gms_reporting_8.0_maint\GMS_Reporting\GMSReporting_NetSource\Reporting\Convertor.cs:line 67</stacktrace><//stacktrace></ stacktrace=""><//><eventsource></eventsource></eventsource><//eventsource>CrystalDecisions.ReportAppServer.DataSetConversion

    Please note: as far as i know DriverName is not required in CrystalReport Decision. so please why it is asking me for a Default driver.

    I have a sybase database. so how make the DRIVER={Sybase ASE ODBC Driver} as default for the application then.

    Thursday, April 05, 2012 10:07 AM

Answers

  • Hi all,

    I got the solution for it.

    For this your "server name" should be the "Data Source Nme " in the System DSN of ODBC Data Source Administrator.

    Please follow the way to fix this problem.

    Goto: Control panel -->

    Administrative Tools --> Data Sources(ODBC).

    Choose System DSN Tab --> Click add (To Create New data Source) --> Choose your Driver from the List --> Finish

    It will open the ODBC Wire protocol Driver Setup

    in the general tab put the server name and port in Network address.

    Please keep in mind your Data Source Name should be same as the server name you want to give in your code.

    test connection will ask you for the login and password credentials.

    Once test connection is done your code will work fine.

    Please reply if you get any issue in this procedure.


    Gyana Ranjan Panda

    • Marked as answer by Gyana Monday, April 09, 2012 11:06 AM
    Monday, April 09, 2012 11:05 AM

All replies

  • Hi, 

    Error clearly saying, 

    Unable to connect: incorrect log on parameters.

    Is your logon credentials are correct? 


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    Thursday, April 05, 2012 11:13 AM
  • Hi Kris444,

    Logon credentials are correct. even i did a lot of google but didn,t find any suitable answer any where.

    Hope you folk might have come accross this and can give a suitable solution. i have completely shared the code even.


    Gyana Ranjan Panda

    Thursday, April 05, 2012 11:43 AM
  • Hi,

    shouldn`t this:

    //Assign the database logon info
                    TableLogOnInfo logon = new TableLogOnInfo();
                    logon.ConnectionInfo.ServerName = "Server Name";                
                    logon.ConnectionInfo.DatabaseName = "DataBaseName";
                    logon.ConnectionInfo.UserID = "User Id";
                    logon.ConnectionInfo.Password = "Password";
                    doc.Database.Tables[0].ApplyLogOnInfo(logon);

    look like:

                    TableLogOnInfo logon = new TableLogOnInfo();
                    logon = doc.Database.Tables[0].LogOnInfo;
                    logon.ConnectionInfo.ServerName = "Server Name";                
                    logon.ConnectionInfo.DatabaseName = "DataBaseName";
                    logon.ConnectionInfo.UserID = "User Id";
                    logon.ConnectionInfo.Password = "Password";
                    doc.Database.Tables[0].ApplyLogOnInfo(logon);


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Thursday, April 05, 2012 11:53 AM
  • Hi Heslacher,

    It didn't create any difference.

    I have a serious question.

    How the crystalreport Connectioninfo is going to know which driver it is going to use, as i have installed SQL Server 2005, Oracle 11g and Sybase on my machine.

    As in connectioninfo we are not passing any data relavant to the driver name.

    As in my case i am pointing to the Sybase Adaptive Server, which should require DRIVER={Sybase ASE ODBC Driver} as part of the connection string. But there is no property at all to whom i can assign the driver name or a complete connection string.

    Plz help


    Gyana Ranjan Panda

    Thursday, April 05, 2012 12:15 PM
  • Any one have any idea on using Driver in crystal report TableLogOnInfo?

    Gyana Ranjan Panda

    Friday, April 06, 2012 9:51 AM
  • I would suggest you to try the following category for more effective responses, where experts live in.

    http://scn.sap.com/welcome?categoryID=1

    Hope it helps.


    Best Regards,
    Rocky Yue[MSFT]
    MSDN Community Support | Feedback to us


    Monday, April 09, 2012 2:44 AM
  • Hi all,

    I got the solution for it.

    For this your "server name" should be the "Data Source Nme " in the System DSN of ODBC Data Source Administrator.

    Please follow the way to fix this problem.

    Goto: Control panel -->

    Administrative Tools --> Data Sources(ODBC).

    Choose System DSN Tab --> Click add (To Create New data Source) --> Choose your Driver from the List --> Finish

    It will open the ODBC Wire protocol Driver Setup

    in the general tab put the server name and port in Network address.

    Please keep in mind your Data Source Name should be same as the server name you want to give in your code.

    test connection will ask you for the login and password credentials.

    Once test connection is done your code will work fine.

    Please reply if you get any issue in this procedure.


    Gyana Ranjan Panda

    • Marked as answer by Gyana Monday, April 09, 2012 11:06 AM
    Monday, April 09, 2012 11:05 AM