Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

DataSet null exception (no replies)

$
0
0
Hi there,

Can anyone give me a "hand" with this problem? I am making a C# app with mysql database server. The aplication has to process 12000 records by day (more or less). My real problem is not the amount of data to process but a strange problem with the adapter of the datatable on the main dataset.


here is the command collection used by the below method:
this._commandCollection[2] = new global::MySql.Data.MySqlClient.MySqlCommand();
this._commandCollection[2].Connection = this.Connection;
this._commandCollection[2].CommandText = @"SELECT `id` FROM `process_roll_parts` WHERE roll_id =@roll_id AND part_id =@part_id";
this._commandCollection[2].CommandType = global::System.Data.CommandType.Text;
param = new global::MySql.Data.MySqlClient.MySqlParameter();
param.ParameterName = "@roll_id";
param.DbType = global::System.Data.DbType.Int64;
param.MySqlDbType = global::MySql.Data.MySqlClient.MySqlDbType.Int64;
param.IsNullable = true;
param.SourceColumn = "roll_id";
this._commandCollection[2].Parameters.Add(param);
param = new global::MySql.Data.MySqlClient.MySqlParameter();
param.ParameterName = "@part_id";
param.DbType = global::System.Data.DbType.Int32;
param.MySqlDbType = global::MySql.Data.MySqlClient.MySqlDbType.Int32;
param.IsNullable = true;
param.SourceColumn = "part_id";
this._commandCollection[2].Parameters.Add(param);

this is the method that I invoque to access the data and get it back:

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
[global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)]
public virtual long GetProcessRollPartsDataByID2(long roll_id, int part_id)
{
this.Adapter.SelectCommand = this.CommandCollection[2];
this.Adapter.SelectCommand.Parameters[0].Value = ((long)(roll_id));
this.Adapter.SelectCommand.Parameters[1].Value = ((int)(part_id));
global::System.Data.ConnectionState previousConnectionState = this.Adapter.SelectCommand.Connection.State;
if (((this.Adapter.SelectCommand.Connection.State & global::System.Data.ConnectionState.Open)
!= global::System.Data.ConnectionState.Open))
{
this.Adapter.SelectCommand.Connection.Open();
}
try
{
int returnValue = int.Parse(this.Adapter.SelectCommand.ExecuteScalar().ToString());
return returnValue;
}
finally
{
if ((previousConnectionState == global::System.Data.ConnectionState.Closed))
{
this.Adapter.SelectCommand.Connection.Close();
}
}
}


The is that in run time the line "this.Adapter.SelectCommand = this.CommandCollection[2];" returns SystemNullNxception, so used the debug and what I find out is that just after the debugger enter this method the "this.CommandCollection[2]" is NULL but if I wait for 2 second it will be not NULL. Anyone has came accross this problem? .Net 4, MySql Connector 6.9.7.0, VS 2013 Community.

Any idear how to repair this issue?

Best regards,
Pedro Dias

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>