Exception DateTime OleDbParameter - visual-studio-2010

I’m using Visual Studio 2010. Within the project we add a DataSet, inside it; we have a Query Table Adapter to do all the queries to a SQL Server 2000 Data Base. One of the queries is formed using a Stored Procedure that receives four parameters. One of the parameters is a DateTime data type. Although we have check many times, we are receiving an unexpected exception:
Provider encountered an error while sending command parameter[0] '' value and stopped processing.
Conversion failed for command parameter[1] '' because the data value overflowed the type used by the provider.
Provider encountered an error while sending command parameter[2] '' value and stopped processing.
Provider encountered an error while sending command parameter[3] '' value and stopped processing.
Provider encountered an error while sending command parameter[4] '' value and stopped processing.
Working around this, if we delete the DateTime parameter of the Store Procedure, the query executes successfully otherwise we get the exception mentioned before.
We notice that the DateTime parameter has the property set as follows:
DbType: DateTime
ProviderType: DBTimeStamp
Any approach trying to accomplish the execution of the Query will be greatly welcome.

When I received this error, I had to change my date parameter to tell what the data type was.
Old Way
cmd.Parameters.Add(new OleDbParameter("TDate", DateTime.Now));
New Way
OleDbParameter dateParam = new OleDbParameter("TDate", OleDbType.Date);
dateParam.Value = DateTime.Now;
cmd.Parameters.Add(dateParam);

Related

Set Properties in Toad Data Point Fails

I am using Toad Data Point V4.0 to connect to Hive. I try to set below properties using Toad.
set hive.input.format=org.apache.hadoop.hive.ql.io.BucketizedHiveInputFormat;
set hive.optimize.bucketmapjoin=true;
set hive.optimize.bucketmapjoin.sortedmerge=true;
While I can set these properties via Beeline, TOAD throws below error when running above set commands.
[Hortonworks][Hardy] (80) Syntax or semantic analysis error thrown in server while executing query. Error message from server: Error while processing statement: Cannot modify input.format at runtime. It is not in list of params that are allowed to be modified at runtime
Wondering if I have to set these properties somewhere in connection setup or not. Appreciate your input.
We've found a very similar issue with DBVis on Hive.
DBVis is stripping the ‘hive.’ off of commands like “set hive.mapred.mode=strict”. It then checks hive’s list of parameters allowed to be set at runtime for the parameter: “mapred.mode” instead of “hive.mapred.mode”. Since it does not find the parameter, it throws and error.
If we preface the parameter by a second “hive.” (for example, “hive.hive.mapred.mode=strict”) DBVis appears to strips off the first “hive.”. It then finds the stripped version as allowed and sends the stripped version to hive where is executes fine.
NB: This only seems to affect parameters beginning with "hive.".

how do i convert a timespan to a string in visual studio

It gives an error,
Exception Details: System.InvalidCastException: Conversion from type 'TimeSpan' to type 'String' is not valid.
Time.Text = datareader1.GetValue(3)
I'm trying to display the data from the database(MS ACCESS), the data display is a time type.
Just call ToString():
Time.Text = datareader1.GetValue(3).ToString()
The fact that you're currently seeing this at execution time suggests that you've got Option Strict set off. (I'm assuming this is VB.) I would suggest having Option Strict on unless you really, really need it off for deliberate late-binding reasons.

ASPxGridView page works for some users, not for others. WebForm model using C#, ASP, SQL Express

I am debugging a website built on the WebForms model, using ASP, C# as codebehind, and SQL Express 2008 R2. I am trying to debug a page that uses an ASPxGridView, which is populated from the .aspx file, and the dataset is uses is created there as well. The data is selected using
SelectCommand="SELECT MachineID, ProgramNo, (CONVERT (VARCHAR(19), Start, 120)) as Start,(CONVERT (VARCHAR(12), Stop,114)) as StopTime, WorkCount, PartCount as TotalWorkCount,(CONVERT (VARCHAR(12), Stop-start,114)) as PartCycle FROM Program WHERE (MachineID = #MachineID) AND (WorkCount > 0) AND (CONVERT (VARCHAR(19), Start, 120) >= #StartDate) AND (CONVERT (VARCHAR(10), Start, 120) <= #EndDate) order by Start Desc">
The problem is that most users can login and the page works perfectly, but a few users see the following error in the web browser:
A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid.
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.Web.HttpException: A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A field or property with name 'PartCycle' was not found in the selected data source. Possible causes of this error may be the following: an incorrect or case-insensitive spelling of the grid column name; assigning a wrong or not properly initialized data source to the grid.]
DevExpress.Web.Data.WebDataControllerProvider.GetRowValueByControllerRow(Int32 controllerRow, String fieldName, Boolean isDesignTime) +300
DevExpress.Web.Data.WebDataControllerProvider.GetRowValue(Int32 visibleIndex, String fieldName, Boolean isDesignTime) +203
DevExpress.Web.Data.WebDataProxy.GetRowValue(Int32 visibleIndex, String fieldName) +77
As you can see, PartCycle is not a column in the tables, but is used as an alias for (CONVERT (VARCHAR(12), Stop-start,114)). To put a twist in the plot, I can view the problem data just fine when I am logged into the site as an Administrator. The users who see this error have various ASPNET Roles, but each have access to the data in the tables selected.
Its because ASPxGridView Caches the Columns.
In your case, your datasource is dynamic i.e. different for different users.
Make sure to Clear the Columns before binding ASPxGridView.
To Clear the Columns:
agvObject.Columns.Clear();

Informatica error =[ERROR('transformation error')]

I am getting the following Informatica error:
Note: Output column [AGENT_DISPOSTION_CODE] has no default value. Row will be skipped if transformation errors are encountered
MAPPING> DBG_21056 column=[PHONE_NUMBER], defaultvalue=[ERROR('transformation error')]
How can I fix it?
It's not an error, it's only an information that you have a port with a default value set to ERROR('transformation error'), so Integration Service will skip the NULL values with an ERROR function.
The Designer inserts this expression automatically, when you add a new output port; you can change it. Edit the expression, find the port on the Ports tab and check the Default value field at the bottom:
The ERROR function causes the Integration Service to skip a row and issue an error message, which you define.
When running a session on the Verbose Data Mode and if there is no default value specified for output ports in the Mapping, PowerCenter is designed for the warning messages to show up in the session log.
During the column initialization, PowerCenter evaluates the default value specified for each output port in the Mapping and displays the corresponding message. The evaluation code path is the same as for evaluating any other expressions later on during data transformation.
Example
If you specify SIN(1.415) as the default value for an output port, the evaluation on sin(1.415) executes successfully. Upon a successful evaluation, the following message will be displayed:
MAPPING> DBG_21364 Note: Default value [SIN(1.4)] of output column [output1] will be used if tansformation errors are encountered
However, if the default value is error('transformation error'), the following error message will be displayed during evaluation like any real transformation errors:
MAPPING> TE_7007 Transformation Evaluation Error [<> [ERROR]: transformation error... nl:ERROR(u:'transformation error')]; current row skipped...
Immediately after the evaluation, the following message will be displayed in the session log:
MAPPING> DBG_21367 Note: Output column [NUM38_37] has no default value. Row will be skipped if transformation errors are encountered

How do I create an instance of Oracle.DataAccess.Client.OracleException to use with NMock

I'm using the Oracle.DataAccess.Client data provider client. I am having trouble constructing a new instance of an OracleException object, but it keeps telling me that there are no public constructors. I saw other having the same problem and tried their solutions, but they don't seem to work. Here's my test code:
object[] args = { 1, "Test Message" };
ConstructorInfo ci = typeof(OracleException).GetConstructor(BindingFlags.NonPublic
| BindingFlags.Instance, null, System.Type.GetTypeArray(args), null);
var e = (OracleException)ci.Invoke(args);
When debugging the test code, I always get a NULL value for 'ci'.
Has Oracle changed the library to not allow this? What am I doing wrong and what do I need to do to instantiate an OracleException object to use with NMock?
By the way, I'm using the Client library for version 10g.
Thanks,
Charlie
OracleException in ODP.NET not the same as OracleException in Microsoft client.
OracleException have 5 constructors information of which you can obtain by GetConstructors().
In the obtained list of the constructors you will see that there are no constructor with parameters (int, string). That why you getting NULL in ci.
If you give a proper list of the parameters you will have proper ConstructorInfo and will be able to call a constructor by Invoke(param);
However, OracleException constructor not designed to be called like this - not all the fields will have a proper information.
2All:
I need following OracleException:
ORA-00001 unique constraint (string.string) violated
ORA-03113 end-of-file on communication channel
ORA-03135: connection lost contact
ORA-12170: TNS: Connect timeout occurred
for testing. How do I create them?

Resources