System.dbnull

Hi,
i am getting the below error message plz help me to resolve the issue
unable to cast object of type 'system.dbnull' to type 'system.string'
Thanks
Murugesan

Hello,
This forum is for discussions and questions regarding profiles and Microsoft's recognition system on the MSDN and TechNet sites. It is not for products/technologies.
As it's off-topic here, I am moving the question to the
Where is the forum for... forum.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

Similar Messages

  • Unable to cast object of type 'System.DBNull' to type 'System.String'.

    Hi,
         I am getting Below error:
    Unable to cast object of type 'System.DBNull' to type 'System.String'. 

    Hello,
    Please confirm whether you are using sharepoint or not. If you are getting this error in sharepoint then Could you share your code with us? and also tell where you are getting this error.
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Error message: Unable to cast object of type 'System.DBNull' to type 'System.String'

    Hi everyone, I have recently installed a trial version of SDL Trados (a computer-assisted translation software) and at some point (when I try to create a new translation memory) this error message appears: Unable to cast object of type 'System.DBNull' to type 'System.String' Is this a problem with the software or the laptop ? If it's the laptop, can you please help me solve this ? Thank you,Caroline

    Actually there was not problem witg the laptop ! Please ignore this topic. Thanks.

  • DBNULL value Error ORA-01084

    Hi,
    I am trying to insert values into a table in a loop using Oracle Parameters where the value could be System.DbNull.Value,but I am getting Exception ORA-01084: invalid argument in OCI call.
    I'm using Oracle-11g r1 DB and ODP.NET-11.1.0.7.10
    Can any one help me please.....
    Thanks in advance
    srikar

    Hi Srikar,
    Is this reproducible on demand? Can you share the code that leads to the failure? Are you able to reproduce the error with a simple single row insert and System.dbNull or is this specific to your loop logic?
    I tested the following and it worked fine.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using Oracle.DataAccess.Client;
    namespace SimnpleInsert
    class Program
    private const string Conn = "Data Source=orcl;User Id=scott;password=tiger";
    private const string sql = "INSERT INTO FOO VALUES (:C1)";
    static void Main(string[] args)
    OracleConnection conn = null;
    OracleCommand cmd = null;
    try
    conn = new OracleConnection(Conn);
    conn.Open();
    cmd = new OracleCommand(sql, conn);
    OracleParameter parm1 = cmd.CreateParameter();
    cmd.Parameters.Add(parm1);
    parm1.ParameterName = "C1";
    parm1.Value = System.DBNull.Value;
    int count = cmd.ExecuteNonQuery();
    Console.WriteLine("Number of Rows Inserted = " + count.ToString());
    cmd.Dispose();
    conn.Close();
    conn.Dispose();
    catch (Exception ex)
    Console.WriteLine(ex.ToString());
    Regards
    Jenny B.

  • Sendings typed Arrays (ArrayBindCount) with DBNull's in the middle

    Hello again,
    I wanted to share another problem I had using ODP against Oracle.
    I need to insert multiple rows into table which allows some parameters to be null.
    Table schema:
    CREATE TABLE ANNOTATIONS
    ANNOTATIONID NUMBER,
    ANNOTATIONNAME NVARCHAR2(64) // this can be null (the same with value types like number)
    Stored proc:
    procedure ANNOTATIONSINSERT( in_ANNOTATIONID in ANNOTATIONS.ANNOTATIONID%type , in_ANNOTATIONNAME in ANNOTATIONS.ANNOTATIONNAME%type)
    AS
    BEGIN
    INSERT INTO ANNOTATIONS ( ANNOTATIONID, ANNOTATIONNAME)
    END;
    Since I use ArrayBindCount mechanism, I use typed arrays (as the type of table column)
    for example (int arrays) and send them to appropriate stored proc.
    What happens when I want to put a DBNull value into one of the integer arrays?
    (I need to use some conversion function: but there is no convert from System.DBNull!)
    Here is a solution I found to this problem: it works although ODP doesn't support
    object types
    private void testCase()
         OracleConnection connection = new OracleConnection(some connection string);
         OracleCommand command = null; // = new OracleCommand("");//, connection);
         BuildANNOTATIONSINSERT(ref command); // I build here command and command parameters
         int total = 20;
         Random random = new Random();
         object [] iData = new object[total]; // YES, instantiate object arrays! and put in arrays true values
         object [] sData = new object[total];
         int data;
         for (int index=0; index<total; index++)
              data = random.Next(40000); // generate some random data
              iData[index] = data;
              if (data%4==0)
                   sData[index] = System.DBNull.Value; // some of the data include null values
              else
                   sData[index] = iData[index].ToString();
         try
              connection.Open();
              IDbTransaction txn = connection.BeginTransaction();
              command.Parameters[0].Value = iData;
              command.Parameters[1].Value = sData;
              command.Connection = connection;
              command.ArrayBindCount = total;
              command.ExecuteNonQuery();
              txn.Commit();
              connection.Close();
         catch (Exception eee)
              MessageBox.Show(eee.Message);
    Should this work, I'm afraid to supply a functionality that works today: to a customer, and at the next
    version of ODP, it will stop working. (and nobody will know why)
    I can also use an error code for any type. (I can decide that -1 is error for NUMBER type and null for string types)
    but I don't want to use that. Usage of objects is also costly (-20% speed performance): it seems that there is
    some encapsulation of types in the core of ODP: byte[][] (also works) etc.
    What is the proper way to do what I want, so it will be safe in the next versions of ODP?
    Thanks!

    Amir,
    ODP.NET accepts array (object array) for array binding. However, passing object array is slower because of the boxing and unboxing of types in .NET (this is not ODP.NET behavior, but .NET). You can pass a type array for array binding, and that should be faster than an object array (boxing and unboxing won't happen). For example, passing an int[] should be faster than object[] for an Oracle Number type.
    However, it is not possible to assign the DBNull.Null value to an element in the type array. In this case, you should make use of the OracleParameter.ArrayBindStatus to inform ODP.NET how to bind the elements in the type array. For example, if the 3rd element is to be treated as Null value, the code will looks like this:
    int[] ints = new Int32[10];
    param.ArrayBindStatus = new OracleParameterStatus[10];
    for (int i = 0; i &lt; 10; i++)
    param.ArrayBindStatus[i] = OracleParameterStatus.Success;
    //Now tell ODP.NET that the 3rd should treat as Null value
    param.ArrayBindStatus[2] = OracleParameterStatus.NullInsert;
    If you use object array instead, setting the element to DBNull.Null should work. But as we mentioned, using object array will then be slower.
    Let us know if we've any question regarding this.
    Thanks
    Martha

  • Sharepoint Foundation 2010 and SSRS

    Hi I have one small problem with Sharepoint Foundation 2010 and SSRS Integrated mode.
    We have one installation with frontend and backend server, backend is installed on SSRS server and Kerberos authentication is enabled.
    There are no problem to view reports with webparts but when you make one automatic subscription to make Report PDF files in one file share, it makes 5 och 30 files.
    I can only find this in log files:
    w3wp!library!18!01/26/2015-19:20:33:: i INFO: Skipped creating a dump file for the error InternalCatalogException, because a dump with the identical stack trace (with signature 1778776910) was already created.
    w3wp!library!18!01/26/2015-19:20:33:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: Unhandled exception in timer Database version check, Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException:
    An internal error occurred on the report server. See the error log for more details. ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.
       at Microsoft.ReportingServices.Library.ConnectionManager.GetDBVersion(Boolean rethrow)
       at Microsoft.ReportingServices.Library.ConnectionManager.EnsureCorrectDBVersion()
       at Microsoft.ReportingServices.Library.ConnectionManager.ConnectStorage(VersionVerificationOptions option)
       at Microsoft.ReportingServices.Library.DatabaseVersionCheckTimer.DoTimerAction()
       at Microsoft.ReportingServices.Diagnostics.TimerActionBase.TimerAction(Object unused)
       --- End of inner exception stack trace ---;
    Any ideas?

    Hi Dalibor,
    Based on your description, my understanding is that the error occurred when automatically making Report PDF files.
    Could you please provide the version of SQL server in your environment?
    If you are using SQL server 2012, I recommend to update the SQL server with SP1 and CU7 to see if the issue still occurs.
    And please also re-configure the Reporting Service Application and then check the results:
    https://technet.microsoft.com/en-us/library/bb326213(v=sql.105).aspx
    https://msdn.microsoft.com/en-us/library/gg492276(v=sql.110).aspx
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • Report Builder 2.0 loses parameter Null default value when deployed

    When a parameter is set to a default value of (Null) and the report is saved to the sever, the default is lost when the report is re-opened in RB2.  This problem doesn't seem to occur in BIDS.  I've tried to use an expression to set the value to System.DBNull but this can no longer be done.
    Any ideas for a work-around?
    Is there a bug report open for this?  I couldn't find an open bug on the Connections site and there's an issue on that site right now when submitting feedback.Paul Turley [Hitachi Consulting]
    SQLServerBIBlog.com

    Hi All,
    I just had an almost identical issue using report builder 3.0 so I don't believe it is fixed. I had 4 parameters set to default to (Null) and I added a new one with identical settings but it would continually come up blank and not check the null box automatically
    when going into my sub report.
    To make matters worse I experimented changing one of the old parameters and it then started exhibiting the same behaviour. Using Luke's post above solved the issue (though it was Manage in my version not Administrate).
    Using System.DBNull.Value resulted in it being treated as a literal string "System.DBNull.Value" and putting that in the filter for me.
    Hope it helps.

  • Issues with changing connection at run-time

    Post Author: dmazourick
    CA Forum: Data Connectivity and SQL
    Weu2019ve tried a lot of different ways to resolve this issue, but are getting every time the different result.
    Probably someone deal with that issue before and know how to correctly resolve it.
    Weu2019re using Crystal Reports Runtime Components X+ (X, XI, XI R2) u2013 all of them has this issue.
    We need client application to connect to multiple data sources u2013 user chooses report, chooses data source and we show the report for specified data source.
    The data sources are tables or stored procedures stored in different databases on different servers.
    For sure, every data source for a single report has the same structure, but that doesnu2019t matter.
    The issue is: when the name of the database on one server is the same as the name of database on second server, the connection caching occurs.
    How we can check that:
    1.       Weu2019re running report for Server1:<DBN> - report shows data from Server1.
    2.       Weu2019re opening second report for Server2:<DBN> - report shows data from Server1.
    3.       Weu2019re closing application and run 1-2 in opposite order, now both reports show data from Server2.
    Weu2019ve tried different approaches u2013 below is a code sample that opens the report for specific connection.
    Juts to be sure that no one will ask u2013 u201CAre you sure youu2019re passing the correct connection info etc.u201D. Yes! We are sure because weu2019re trying to fix this issue for a long time and tried a lot of different approaches and still cannot find the right solution.
    The code looks like below. This is VB6 code, but also the same situation was tried on VC++ 6.0
    Weu2019re not looking into CR.NET solution for now.
    =================================================
    Sub DisplayReport(Server as String, DB as String, UID as String, PWD as String, viewer as Object)
        Dim app As New CRAXDRT.Application
        Dim report As CRAXDRT.report
        Dim database As CRAXDRT.database
        Dim table As CRAXDRT.DatabaseTable
        Dim par As CRAXDRT.ParameterFieldDefinition
        Set report = app.OpenReport("D:\TestReport_X.rpt")
        report.database.LogOnServer "pdssql.dll", Server, DB, UID, PWD
        Set table = report.database.Tables(1)
        table.SetLogOnInfo Server, DB, UID, PWD
        table.Location = table.Name
        report.database.Verify
        viewer.ReportSource = report
        viewer.ViewReport
    end sub
    =================================================
    The result of above code is the following:
    1.       If we will pass the same viewer and will use different Server u2013 the report will be displayed correctly
    2.       If we will pass different viewers and will use different Server u2013 the reports will contain same data
    The result of above code also depends from the version of Crystal Reports the report was designed in:
    1.       For Report designed in 8.5 u2013 passing of the same viewer with same connection info second time will refresh report
    2.       For Report designed in X, XI, XI R2 u2013 no refresh
    Also, a slight modification of the above code helps for reports designed in XI to work properly, but not for reports designed in X and 8.5:
    1.       Before calling LogonServer, make the following: DB = DB & u201C;u201D & Int(rnd()*32767)
    That makes report designed in XI to display properly in different viewers, but doesnu2019t have any impact to X and no any impact to 8.5
    Weu2019re really looking for any help in this question

    Post Author: fburch
    CA Forum: Data Connectivity and SQL
    I am having similar problems and some successes.
    I have 70+ reports and now suddenly I want to point them at two different servers, but at databases with the same name like you talked about.
    I first just tried the following:
    #1. Load report:
    Dim myReport As New ReportDocument
    myReport.Load(filename)
    #2. Pass in parameter values
    ''Get the collection of parameters from the report
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions = r.DataDefinition.ParameterFields
    ''Access the specified parameter from the collection
    Dim crParameter1 As ParameterFieldDefinition = crParameterFieldDefinitions.Item(ParamName)
    ''Get the current values from the parameter field. At this point
    ''there are zero values set.
    'crParameter1Values = crParameter1.CurrentValues
    ''Set the current values for the parameter field
    Dim crDiscrete1Value As New ParameterDiscreteValue
    If crParameter1.ValueType = FieldValueType.DateField Or crParameter1.ValueType = FieldValueType.DateTimeField Then
    If ParamValue Is System.DBNull.Value Then
    crDiscrete1Value.Value = CDate("1/1/1900")
    ElseIf ParamValue Is Nothing Then
    crDiscrete1Value.Value = CDate("1/1/1900")
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    ElseIf crParameter1.ValueType = FieldValueType.StringField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = ""
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    ElseIf crParameter1.ValueType = FieldValueType.BooleanField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = False
    ElseIf ParamValue.ToString.ToUpper = "TRUE" Then
    crDiscrete1Value.Value = True
    Else
    crDiscrete1Value.Value = False
    End If
    ElseIf crParameter1.ValueType = FieldValueType.NumberField Then
    If ParamValue Is Nothing Then
    crDiscrete1Value.Value = 0
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    Else
    If ParamValue Is System.DBNull.Value Then
    crDiscrete1Value.Value = Nothing
    ElseIf ParamValue Is Nothing Then
    crDiscrete1Value.Value = Nothing
    Else
    crDiscrete1Value.Value = ParamValue
    End If
    End If
    ''Add the first current value for the parameter field
    Dim crParameter1Values As New ParameterValues
    crParameter1Values.Add(crDiscrete1Value)
    ''All current parameter values must be applied for the parameter field.
    crParameter1.ApplyCurrentValues(crParameter1Values)
    #3 Set "Table Log in info" (most of my reports using stored procedures, but I guess I still needed this step).
    Dim CrTables As Tables = r.Database.Tables
    Dim CrTable As Table
    Dim crtableLogoninfos As New TableLogOnInfos()
    Dim crtableLogoninfo As New TableLogOnInfo()
    With crConnectionInfo
    .ServerName = connectionParser.GetServerName(connectionString)
    .DatabaseName = connectionParser.GetDatabaseName(connectionString)
    If connectionParser.DoesUseIntegratedSecurity(connectionString) = True Then
    .IntegratedSecurity = True
    Else
    .UserID = connectionParser.GetServerUserName(connectionString)
    .Password = connectionParser.GetServerPassword(connectionString)
    .IntegratedSecurity = False
    End If
    End With
    For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    If InStr(CrTable.Location, ".dbo.") = 0 Then
    CrTable.Location = crConnectionInfo.DatabaseName + ".dbo." + CrTable.Location
    End If
    Next
    If r.Subreports.Count > 0 Then
    Dim crSections As Sections
    Dim crSection As Section
    Dim crReportObjects As ReportObjects
    Dim crReportObject As ReportObject
    Dim crSubreportObject As SubreportObject
    Dim crDatabase As Database
    Dim subRepDoc As New ReportDocument()
    'SUBREPORTS
    'Set the sections collection with report sections
    crSections = r.ReportDefinition.Sections
    'Loop through each section and find all the report objects
    'Loop through all the report objects to find all subreport objects, then set the
    'logoninfo to the subreport
    For Each crSection In crSections
    crReportObjects = crSection.ReportObjects
    For Each crReportObject In crReportObjects
    If crReportObject.Kind = ReportObjectKind.SubreportObject Then
    'If you find a subreport, typecast the reportobject to a subreport object
    crSubreportObject = CType(crReportObject, SubreportObject)
    'Open the subreport
    subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
    crDatabase = subRepDoc.Database
    CrTables = crDatabase.Tables
    'Loop through each table and set the connection info
    'Pass the connection info to the logoninfo object then apply the
    'logoninfo to the subreport
    For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    If InStr(CrTable.Location, ".dbo.") = 0 Then
    CrTable.Location = crConnectionInfo.DatabaseName + ".dbo." + CrTable.Location
    End If
    Next
    End If
    Next
    Next
    #4 go get the data
    crv.ReportSource = myReport
    crv.Refresh()
    #5 Call export to disk function.
    This was not changing server - did not realize it was a caching problem as you suggested. That makes sense. So anyway, then of course I threw a verify database statement on there, before I get the data. Now looks like this:
    #1 Load Report
    #2. Pass in parameter values (dummy values that will generate schema of table without having to actually run long running procedures, i.e. select (cast 1 as int) as somefield1, cast(2.0 as numeric(10,0)) as somefield2
    #3 Set "Table Log in info"
    #3b Verify the database which seems to be a necessity:
    myReport.VerifyDatabase()
    #3c Re-populate the report with real parameter values, same as #2 but this time with the ones that will generate the real data
    #4 go get the data
    #5 Call export to disk function.
    This does work, some of the time. When the datasource underlying report are tables, it works. I made a dummy crystal report with lots of different types of params (stored procedure underlying database) - this also worked!
    Unfortunately, when I run this against the majority of my reports, I get this stupid "invalid mapping type value", for which I have not been able to resolve yet.
    I also tried putting a myreport.SetDatabaseLogon("","") -- what would this do, clear it out? (saw this referenced somewhere).
    Then I tried putting the real connection info in there as well ...
    myReport.SetDatabaseLogon(uid, pwd, serverName, DBname)
    I put this setdatabase thing before I called verifydatabase, which is where the process is bombing out and giving me invalid mapping type for the reports that do not run.
    At this point I am still working on solution. I have tried creating dummy report that used same parameter types as a report that was failing and voila - the dummy report worked. Anyway, let me know if you get your problem fixed and I will do the same. Looks like you are using a different method that I didn't notice "LogOnServer"

  • Database Logon Failed which created by Crystal Report 2008

    this time i meet the famous error again which is database logon failed.
    i created a crystal report 2008 starting from blank report, then connect with odbc
    i use 2008 method
    objRpt.SetDatabaseLogon(db_username, db_password, odbc_name, database_name);
    2008 method will get database logon failed even set database location and verify database again
    then i use 8.5 method and try again for 2008 report. it said field name is unknown for one of formula
    then i drag field again for formula and set database location and verify database again
    it said the same error.
    then i uninstall 8.5 crytal report software in window 7 deployment machine, and do above again, it said the same error
    //'Create a new Stored Procedure Table to replace the reports current table.
            CrystalDecisions.ReportAppServer.DataDefModel.Procedure boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();
            //'boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
            PropertyBag boMainPropertyBag = new PropertyBag();
            //'boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
            //'In the main property bag (boMainPropertyBag)
            PropertyBag boInnerPropertyBag = new PropertyBag();
            //'Set the attributes for the boInnerPropertyBag
            boInnerPropertyBag.Add("Connect Timeout", "15");
            //boInnerPropertyBag.Add("Data Source", "MyDataSource");
            boInnerPropertyBag.Add("Data Source", "10.1.1.191");
            boInnerPropertyBag.Add("DataTypeCompatibility", "0");
            boInnerPropertyBag.Add("General Timeout", "0");
            //boInnerPropertyBag.Add("Initial Catalog", "MyCatalog");
            boInnerPropertyBag.Add("Initial Catalog", database_name);
            boInnerPropertyBag.Add("Integrated Security", "False");
            boInnerPropertyBag.Add("Locale Identifier", "1033");
            boInnerPropertyBag.Add("MARS Connection", "0");
            //boInnerPropertyBag.Add("OLE DB Services", "-5");
            //boInnerPropertyBag.Add("ODBC", "-5");
            boInnerPropertyBag.Add("ODBC", "Cheque");
            boInnerPropertyBag.Add("Provider", "SQLNCLI");
            boInnerPropertyBag.Add("Tag with column collation when possible", "0");
            boInnerPropertyBag.Add("Trust Server Certificate", "0");
            boInnerPropertyBag.Add("Use Encryption for Data", "0");
            //'Set the attributes for the boMainPropertyBag
            boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
            //boMainPropertyBag.Add("Database DLL", "p2sodbc.dll");
            //boMainPropertyBag.Add("QE_DatabaseName", "VEPILOT");
            boMainPropertyBag.Add("QE_DatabaseName", database_name);
            //boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
            boMainPropertyBag.Add("QE_DatabaseType", "ODBC");
            //'Add the QE_LogonProperties we set in the boInnerPropertyBag Object
            boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
            boMainPropertyBag.Add("QE_ServerDescription", "MyServer");
            boMainPropertyBag.Add("QE_SQLDB", "True");
            boMainPropertyBag.Add("SSO Enabled", "False");
            //'Create a new ConnectionInfo object
            CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
            //'Pass the database properties to a connection info object
            boConnectionInfo.Attributes = boMainPropertyBag;
            //'Set the connection kind
            boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
            //'*EDIT* Set the User Name and Password if required.
            boConnectionInfo.UserName = db_username;
            boConnectionInfo.Password = db_password;
            //'Pass the connection information to the table
            boTable.ConnectionInfo = boConnectionInfo;
    CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables = objRpt.ReportClientDocument.DatabaseController.Database.Tables;
                CrystalDecisions.CrystalReports.Engine.Tables tables = objRpt.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
                    if (!string.IsNullOrEmpty(table.Name))
                        //boTable.Name = table.Name;
                        //boTable.QualifiedName = database_name + ".dbo." + table.Name;
                        //boTable.Alias = table.Name;
                        boTable.Name = "sp_ChequeIssueDetRpt";
                        boTable.QualifiedName = database_name + ".dbo.sp_ChequeIssueDetRpt";
                        boTable.Alias = "sp_ChequeIssueDetRpt";
                        objRpt.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);
                objRpt.VerifyDatabase();
    http://sourceforge.net/projects/aspchequesprint/files/ChequeIssueDet.rpt/download

    No subreport, only a stored procedure with final two lines are
    print @m_sql
    exec (@m_sql)
    After use generated code in the link above
    Error at boReportDocument.VerifyDatabase();
    Inner Exception : no error
    Message "Logon failed"
    ErrorID : CrystalDecisions.CrystalReports.Engine.EngineExceptionErrorID.LogOnFailed
    HelpLink : null
    stacktrace :  CrystalDecisions.CrystalReports.Engine.ReportDocument.VerifyDatabase()\r\n   at viewReport.Page_Load(Object sender, EventArgs e) 於 d:
    Data
    My Documents
    Visual Studio 2008
    WebSites
    Cheques
    viewReport.aspx.cs: row 1302\r\n   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)\r\n   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n   at System.Web.UI.Control.OnLoad(EventArgs e)\r\n   at System.Web.UI.Control.LoadRecursive()\r\n   於 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    TargetSite : {Void VerifyDatabase()}
    string reportPath = report_path + "ChequeIssueDet.rpt";
                boReportDocument = new ReportDocument();
                //**EDIT** Change the path and report name to the report you want to change.
                boReportDocument.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
                //Create a new Stored Procedure Table to replace the reports current table.
                CrystalDecisions.ReportAppServer.DataDefModel.Procedure boTable =
                new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();
                //boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
                PropertyBag boMainPropertyBag = new PropertyBag();
                //boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
                //In the main property bag (boMainPropertyBag)
                PropertyBag boInnerPropertyBag = new PropertyBag();
                //Set the attributes for the boInnerPropertyBag
                boInnerPropertyBag.Add("Database", database_name);
                boInnerPropertyBag.Add("DSN", "Cheque");
                boInnerPropertyBag.Add("UseDSNProperties", "False");
                //Set the attributes for the boMainPropertyBag
                boMainPropertyBag.Add("Database DLL", "crdb_odbc.dll");
                boMainPropertyBag.Add("QE_DatabaseName", database_name);
                boMainPropertyBag.Add("QE_DatabaseType", "ODBC (RDO)");
                //Add the QE_LogonProperties we set in the boInnerPropertyBag Object
                boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
                boMainPropertyBag.Add("QE_ServerDescription", "Cheque");
                boMainPropertyBag.Add("QE_SQLDB", "True");
                boMainPropertyBag.Add("SSO Enabled", "False");
                //Create a new ConnectionInfo object
                CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =
                new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
                //Pass the database properties to a connection info object
                boConnectionInfo.Attributes = boMainPropertyBag;
                //Set the connection kind
                boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
                //**EDIT** Set the User Name and Password if required.
                boConnectionInfo.UserName = db_username;
                boConnectionInfo.Password = db_password;
                //Pass the connection information to the table
                boTable.ConnectionInfo = boConnectionInfo;
                //Get the Database Tables Collection for your report
                CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;
                boTables = boReportDocument.ReportClientDocument.DatabaseController.Database.Tables;
                //For each table in the report:
                // - Set the Table Name properties.
                // - Set the table location in the report to use the new modified table
                boTable.Name = "sp_ChequeIssueDetRpt;1";
                boTable.QualifiedName = database_name+".dbo.sp_ChequeIssueDetRpt;1";
                boTable.Alias = "sp_ChequeIssueDetRpt;1";
                boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);
                //Verify the database after adding substituting the new table.
                //To ensure that the table updates properly when adding Command tables or Stored Procedures.
                boReportDocument.VerifyDatabase();
                //**EDIT** Set the value for the Stored Procedure parameters.
                string m_curUser = "";
                int spid = Convert.ToInt32(Request.Cookies["login_cookie"]["spid"]);
                queryString = "select * from v_All_Session where SPID=" + spid.ToString();
                //string _connectionString = ConfigurationManager.ConnectionStrings["ChequeConnectionString"].ConnectionString;
                using (SqlConnection connection = new SqlConnection(_connectionString))
                    SqlCommand command = connection.CreateCommand();
                    command.CommandText = queryString;
                    connection.Open();
                    using (SqlDataReader datareader = command.ExecuteReader())
                        if (datareader.HasRows == true)
                            while (datareader.Read())
                                if (datareader["UserID"] != System.DBNull.Value)
                                    m_curUser = datareader["UserID"].ToString();
                        datareader.Close();
                    connection.Close();
                boReportDocument.SetParameterValue("@UserID", m_curUser);
                if (string.IsNullOrEmpty(Session["fm_CoCode"].ToString()))
                    boReportDocument.SetParameterValue("@fm_CoCode", Session["fm_CoCode"].ToString());
                if (string.IsNullOrEmpty(Session["to_CoCode"].ToString()))
                    boReportDocument.SetParameterValue("@to_CoCode", Session["to_CoCode"].ToString());
                if (string.IsNullOrEmpty(Session["fm_BankACNo"].ToString()))
                    boReportDocument.SetParameterValue("@fm_BankACNo", Session["fm_BankACNo"].ToString());
                if (string.IsNullOrEmpty(Session["to_BankACNo"].ToString()))
                    boReportDocument.SetParameterValue("@to_BankACNo", Session["to_BankACNo"].ToString());
                if (string.IsNullOrEmpty(Session["fm_BatchNo"].ToString()))
                    boReportDocument.SetParameterValue("@fm_BatchNo", Session["fm_BatchNo"].ToString());
                if (string.IsNullOrEmpty(Session["to_BatchNo"].ToString()))
                    boReportDocument.SetParameterValue("@to_BatchNo", Session["to_BatchNo"].ToString());
    Edited by: Mathew_666 on Jul 19, 2011 4:27 AM
    Edited by: Mathew_666 on Jul 19, 2011 4:28 AM

  • Wrong number or types of parameters after upgrading to ODP 11.2.0.1.1 Beta

    Hi,
    I have the below Oracle procedure with two parameters , the first one i IS TABLE OF number INDEX BY BINARY_INTEGER, and the second one is of type Ref cursor of predifned RECORD type.
    PROCEDURE Proc1(p_proj_comp_no_list IN core_util.ref_t,
    p_proj_comp_post_query_cursor OUT t_proj_comp_post_query_cursor
    ) IS
    This has been working fine while we were using DEVART Oracle drivers. however, as soon we move to ODP 11.2.0.1.1 Beta version we get the below error while executing the procedure via ODP.
    {"ORA-06550: line 1, column 7:\nPLS-00306: wrong number or types of arguments in call to 'PROJ_COMP_POST_QUERY'\nORA-06550: line 1, column 7:\nPL/SQL: Statement ignored"}
    Below is the debug watch result of the two parameters of the COMMAND being executed.
    Best Regards,
    Prabhakar
    +          *base     {P_PROJ_COMP_NO_LIST}     System.Data.Common.DbParameter {Oracle.DataAccess.Client.OracleParameter}*
              ArrayBindSize     null     int[]
              ArrayBindStatus     null     Oracle.DataAccess.Client.OracleParameterStatus[]
              CollectionType     None     Oracle.DataAccess.Client.OracleCollectionType
              DbType     String     System.Data.DbType
              Direction     Input     System.Data.ParameterDirection
              IsNullable     false     bool
              Offset     0     int
              OracleDbType     Long     Oracle.DataAccess.Client.OracleDbType
              OracleDbTypeEx     Long     Oracle.DataAccess.Client.OracleDbType
              ParameterName     "P_PROJ_COMP_NO_LIST"     string
              Precision     0     byte
              Scale     0     byte
              Size     1     int
              SourceColumn     ""     string
              SourceColumnNullMapping     false     bool
              SourceVersion     Current     System.Data.DataRowVersion
              Status     Success     Oracle.DataAccess.Client.OracleParameterStatus
              UdtTypeName     ""     string
    +          Value     {long[1]}     object {long[]}
    +          Static members          
    +          Non-Public members          
    -          [1]     {P_PROJ_COMP_POST_QUERY_CURSOR}     object {Oracle.DataAccess.Client.OracleParameter}
    +          *base     {P_PROJ_COMP_POST_QUERY_CURSOR}     System.Data.Common.DbParameter {Oracle.DataAccess.Client.OracleParameter}*
              ArrayBindSize     null     int[]
              ArrayBindStatus     null     Oracle.DataAccess.Client.OracleParameterStatus[]
              CollectionType     None     Oracle.DataAccess.Client.OracleCollectionType
              DbType     Object     System.Data.DbType
              Direction     Output     System.Data.ParameterDirection
              IsNullable     false     bool
              Offset     0     int
              OracleDbType     RefCursor     Oracle.DataAccess.Client.OracleDbType
              OracleDbTypeEx     RefCursor     Oracle.DataAccess.Client.OracleDbType
              ParameterName     "P_PROJ_COMP_POST_QUERY_CURSOR"     string
              Precision     0     byte
              Scale     0     byte
              Size     0     int
              SourceColumn     ""     string
              SourceColumnNullMapping     false     bool
              SourceVersion     Current     System.Data.DataRowVersion
              Status     Success     Oracle.DataAccess.Client.OracleParameterStatus
              UdtTypeName     ""     string
    +          Value     {}     object {System.DBNull}
    +          Static members          
    +          Non-Public members

    Hi,
    Can you please show the actual code that creates and appends the parameters instead, along with cmd.commandtext?
    Thanks
    Greg
    Edited by: gdarling on Jun 30, 2010 11:54 AM
    Also note that unless you're using Oracle Developer Tools for VS to generate the code, this would probably be more appropriate in the ODP forum:
    ODP.NET

  • Unable to cast object of type OracleXmlType to type XmlDocument

    Hello All:
    I have an Oracle Procedure that is taking an XML Document as an output parameter.
    oCommand.Parameters.Add("errorrecord", OracleDbType.XmlType).Value = System.DBNull.Value;
    oCommand.Parameters["errorrecord"].Direction = System.Data.ParameterDirection.Output;
    When I try to cast this as an XmlDocument so I can set it to my ErrorRecord variable (defined as XmlDocument) and pass it back out of the Web-Service
    ErrorRecord = (XmlDocument)oCommand.Parameters["p_errorrecord"].Value;
    I get the following error: "Unable to cast object of type 'Oracle.DataAccess.Types.OracleXmlType' to type 'System.Xml.XmlDocument'"
    How do I cast / convert the Oracle XMLType back to a .Net XMLDocument to pass out of the function?
    Thanks

    No, I have not tried that yet, but I admit I don't fully understand the syntax in the document posted.
    oCommand.Parameters.Add("p_errorrecord", OracleDbType.XmlType).Value = System.DBNull.Value;
    ErrorRecord = GoCommand.Parameters["errorrecord"].Value; (this is returned as XmlType)
    I don't quite understand the syntax in the posted URL:
    Declaration
    // C#
    public XmlDocument GetXmlDocument();
    How am I to use this to get the XMLDocument?

  • SQL server agent send email

    I set up email notification for a job completes. I configured database mail profile and mail account. This works fine and I can send out test email.
    However, the SQL agent couldn't send out email and when I tried to restart the SQL server agent, I got the following errors:
    Message
    [260] Unable to start mail session (reason: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException: Mail configuration information could not be read from the database. ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull'
    to type 'System.Byte[]'.
       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)
       --- End of inner exception stack trace ---
       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)
    My SQL server is SQL 2008 with service pack 3.
    Anybody has any idea what's the problem is?
    Thanks

    Hi Ying,
    You could try below suggestions.And restart SQL Server Agent.
    Please refer:
    http://www.developerjoint.com/kb/9363-trouble-with-sql-2005-database-mail.aspx.
    Thanks,
    Maggie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

  • GetRows(), GetXML() VS. Oracle Objects...

    Hi!
    I've been working with OO4O for 2-3 months now. Since the Dynaset is RIDICULOUSLY slow, I always use GetRows() to get my data. But when I call GetRows() in a Dynaset containing objects (i.e. OraObject), all the objects fields are set to Nothing (or Empty string). If I fetch them using the Dynaset itself (not GetRows()), it works. Why ? All the other fields (VARCHAR, NUMBER, DATE) works fine, but not the objects. Here's a copy paste of my watch window, (7,0) and (7,1) are suppose to be objects, but they show up as empty strings. I've looked in the documentation and it doesnt say anything about objects now beeing supported by GetRows().
         (0,0)     "909349"     String
         (0,1)     "2372636"     String
         (1,0)     "0"     String
         (1,1)     "0"     String
         (2,0)     "87"     String
         (2,1)     "90"     String
         (3,0)     "1"     String
         (3,1)     "1"     String
         (4,0)     "production"     String
         (4,1)     "production"     String
         (5,0)     #10/26/2001 9:22:24 AM#     Date
         (5,1)     #12/10/2001 2:39:45 PM#     Date
         (6,0)     "11"     String
         (6,1)     "11"     String
         (7,0)     ""     String
         (7,1)     ""     String
    +     (8,0)     {System.DBNull}     System.DBNull
    +     (8,1)     {System.DBNull}     System.DBNull
    Also, I tried using GetXML() as some sort of lame workaround, and I noticed that when I call GetXML() on a dynaset containing objects, only the first object of the table/query is exported. Look at the XML file below, it's the same query. I am 100% sure that DEVICE_ID = 2372636 HAS a COORD value set, but it's not in there.
    Debug.WriteLine(s)
    <?xml version = "1.0" encoding = "ISO-10646-UCS-2"?>
    <ROWSET>
    <ROW id="1">
    <DEVICE_ID>909349</DEVICE_ID>
    <STATUS>0</STATUS>
    <ANGLE>87</ANGLE>
    <SCALE>1</SCALE>
    <LM_USER>production</LM_USER>
    <LM_DATETIME>2001-10-26 09:22:24</LM_DATETIME>
    <DEV_DEF_ID>11</DEV_DEF_ID>
    <COORD>
    <SDO_GTYPE>2001</SDO_GTYPE>
    <SDO_POINT>
    <X>810871,97</X>
    <Y>14262677,79</Y>
    <Z>0</Z>
    </SDO_POINT>
    <SDO_ELEM_INFO> </COORD>
    </ROW>
    <ROW id="2">
    <DEVICE_ID>2372636</DEVICE_ID>
    <STATUS>0</STATUS>
    <ANGLE>90</ANGLE>
    <SCALE>1</SCALE>
    <LM_USER>production</LM_USER>
    <LM_DATETIME>2001-12-10 14:39:45</LM_DATETIME>
    <DEV_DEF_ID>11</DEV_DEF_ID>
    <COORD>
    </COORD>
    </ROW>
    </ROWSET>
    All these OO4O issues are slowing down development. You guys owe me some explanation. PLEASE REPLY FAST!
    Mathieu Gauthier
    JCMB Technology Inc.

    Please note that Metalink is the appropriate forum if you're seeking support from Oracle. These forums are designed for third party developer-to-developer interactions, though Oracle folks may periodically wander by to contribute.
    Justin

  • Serialize String containing only whitespace such as a " " character

    I'm having dufficulty figuring out how to serialize a String property
    [XmlElement("DescriptionDelimiter1")]
    public String DescriptionDelimiter1
        get { return _DescriptionDelimiter1; }
        set { _DescriptionDelimiter1 = value; }
    Granted, I don't really need the XmlElement tag but just in case I want to change the name of the XML element...
    Anyway, what I get in XML is
    <ImportProfiles>
      <ImportProfile Name="HPH Import Profile">
        <ConcatenateDescriptions>true</ConcatenateDescriptions>
        <DescriptionDelimiter1 />
        <DescriptionDelimiter2>\r\n</DescriptionDelimiter2>
        <DescriptionDelimiter3>\t</DescriptionDelimiter3>
      <ImportProfile>
    </ImportProfiles>
    The problem is when serialized, if the value is " " or a single space, the result is <DescriptionDelimiter1 /> which when deserialized sets the string's value to "" with is not the value I need. I've looked into using CData but there doesn't seem to be a simple way to implement it... I expect
    <DescriptionDelimiter1> </DescriptionDelimiter1>
    or
    <DescriptionDelimiter1><[CDATA[ ]]></DescriptionDelimiter1>
    Is there some setting I can use when serializing the object to indication the process should not trim away whitespace?
    The following is the method used to serialize my object:
    public static String Serialize(DataImportBase dib)
        System.Type[] ArrType = new Type[1];
        ArrType[0] = typeof(System.DBNull);
        XmlSerializer xs = new XmlSerializer(typeof(DataImportBase), ArrType);
        System.IO.MemoryStream aMemoryStream = new System.IO.MemoryStream();
        xs.Serialize(aMemoryStream, dib);
        return System.Text.Encoding.UTF8.GetString(aMemoryStream.ToArray());
    Thanks for any assistance!!!
    Chris

    I have looked through the classes for XML serialization but I haven't found anything that seems to allow one to set that attribute xml:space declaratively on members.
    One way to change the serialization behaviour would be to write a specialized XmlWriter that takes a list of element names for which it writes out the xml:space attribute. This can be done with a few lines if you use the XmlWrappingWriter from the project http://www.codeplex.com/Wiki/View.aspx?ProjectName=MVPXML. The code for XmlWrappingWriter is also shown in Oleg's blog.
    If you use that then you can set up a specialized XmlWriter as follows:
    public class XmlSpaceWriter : XmlWrappingWriter
    private XmlQualifiedName[] ElementNames;
    public XmlSpaceWriter(TextWriter output, XmlQualifiedName[] elementNames)
    : base(XmlWriter.Create(output))
    ElementNames = elementNames;
    public override void WriteStartElement(string prefix, string localName, string ns)
    base.WriteStartElement(prefix, localName, ns);
    foreach (XmlQualifiedName name in ElementNames)
    if (name.Namespace == ns && name.Name == localName && base.XmlSpace != XmlSpace.Preserve)
    base.WriteAttributeString("xml", "space", "http://www.w3.org/XML/1998/namespace", "preserve");
    break;
    and use it like this
    Foo foo = new Foo();
    foo.Bar = " ";
    foo.Example = " ";
    XmlSerializer serializer = new XmlSerializer(typeof(Foo));
    StringWriter stringWriter = new StringWriter();
    XmlSpaceWriter spaceWriter = new XmlSpaceWriter(stringWriter, new XmlQualifiedName[] {new XmlQualifiedName("Bar")});
    serializer.Serialize(spaceWriter, foo);
    spaceWriter.Close();
    string markup = stringWriter.ToString();
    The result then looks like this:
    <?xml version="1.0" encoding="utf-16"?><Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Bar xml:space="preserve"> </Bar><Example> </Example></Foo>
    The example code above has just one constructor for a TextWriter but the code could obviously easily extended to have further constructors taking e.g. a stream.

  • RunspaceFactory.CreateRunspace() & Exchange Server 2010

    Hi, I'm in my first attempt in creating an aspx.vb script which accepts inputs from the front end and executes a powershell script. I have a couple of questions.
    1.The exchange powershell script requires input parameters prior to script execution e.g. “./check.ps1 –parameter1 [input] –parameter2 [input]"
    2.How do I close the Runspace session? / use the system.dbnull etc…
    ' Create a RunSpace to host the Powershell script environment using RunspaceFactory.CreateRunSpace.
    Dim runSpace As Runspace = RunspaceFactory.CreateRunspace()
    runSpace.Open()
    ' Create a Pipeline to host commands to be executed using Runspace.CreatePipeline.
    'Dim ID As String
    'Dim CSVPATH As String
    Dim q As Object = System.IO.Directory.GetCurrentDirectory().ToString
    Dim r As Object = TextBox1.Text
    Dim pipeLine As Pipeline = runSpace.CreatePipeline()
    ' Create a Command object by passing the command to the constructor.
    Dim PSTPSStarted As New Command("D:\Reports\Check.ps1")
    PSTPSStarted.Parameters.Add("ID", "r")
    PSTPSStarted.Parameters.Add("CSVPATH", "q")
    ' Add the commands to the Pipeline.
    pipeLine.Commands.Add(PSTPSStarted)
    StatusLabel.Text = "Upload status:" & PSTPSStarted.ToString
    ' Run all commands in the current pipeline by calling Pipeline.Invoke
    pipeLine.Invoke()
    ' dispose the pipeline
    pipeLine.Dispose()
    'dispose the runspace
    runSpace.Dispose()
    runSpace.Close()

    1. If this is Exchange 2010 then you might want to take a look at
    http://blogs.msdn.com/b/akashb/archive/2010/03/26/how-to-call-ps1-script-from-managed-code-using-remote-powershell-exchange-2010.aspx as you are missing the Remote Powershell connection to make the Exchange side of it work. This also has a sample of how
    to pass variables into a script.
    2. Make sure you Close the Runspace before calling Dispose (your calling Dispose before Close). Although its better to reuse the Runspace's if you going to be running a lot of commands rather then creating a new session each time.
    Cheers
    Glen
     

Maybe you are looking for

  • Itunes Library will not open!!!!!    itunes Library will not open!!!!!

    Hello, This is very frustrating that hundreds of people view these questions and only a few people answer. The issue here is that my itunes Library will not open. I'd sure like to know what is causing this and if it's gone forever. WinXP. Pro. I have

  • Satellite A660 - USB boot problems after BIOS update

    Hello, I own a Toshiba Satellite A660 and recently have update the BIOS to the latest version (1.80). Since then the notebook will freeze on the boot screen (the one with the Toshiba logo) whenever a USB flash memory is attached. It works without the

  • Aperture 3.0 slower than version 2

    Hi, I recently purchased Aperture 3 because of the new features which I think are really good. Furthermore I expected version 3 at lease a little bit faster than older versions. In contrary Aperture 3 is as slow as it can be! It regularly stops my en

  • PDFMaker bookmarks broken or extra characters

    My configuration: Windows XP SP2 Acrobat 8 Pro Word 2000 When I attempt to create bookmarks automatically using the options in PDFMaker, the resulting bookmarks are broken and the bookmarked headings have extra characters in front of them. By broken,

  • Sharing my songs on two of MY computers

    I purchased all my iTunes music from my desktop computer, and now would like to try and have a copy of all of the files backed up onto my laptop. Is there a way to have all my iTunes music copied over to my laptop? I've tried copying all the folders