Click here to Skip to main content
15,914,222 members
Home / Discussions / Windows Forms
   

Windows Forms

 
AnswerRe: ListView Virtual data from disk Pin
Mycroft Holmes2-Apr-09 22:14
professionalMycroft Holmes2-Apr-09 22:14 
GeneralRe: ListView Virtual data from disk Pin
Polity3-Apr-09 5:51
Polity3-Apr-09 5:51 
QuestionSourceGrid, how to use different fonts in different cells Pin
balukg2-Apr-09 5:01
balukg2-Apr-09 5:01 
AnswerRe: SourceGrid, how to use different fonts in different cells Pin
Henry Minute2-Apr-09 6:59
Henry Minute2-Apr-09 6:59 
QuestionIs it possible to shadow IsMdiContainer? Pin
Gregory Gadow1-Apr-09 16:47
Gregory Gadow1-Apr-09 16:47 
AnswerRe: Is it possible to shadow IsMdiContainer? Pin
Colin Angus Mackay1-Apr-09 23:49
Colin Angus Mackay1-Apr-09 23:49 
GeneralRe: Is it possible to shadow IsMdiContainer? Pin
Gregory Gadow2-Apr-09 3:37
Gregory Gadow2-Apr-09 3:37 
QuestionOnly MySqlParameter objects may be stored Pin
naim khan1-Apr-09 11:21
naim khan1-Apr-09 11:21 
Hello evryone,

When i m build my projcet. that is successfully build but when i m debuging they give me this exception . i dont know why. please help me . i did not solved my problem.
what is the meaning of this Excetion. please help me .

Code......

using System;
using System.Xml.XPath;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Xml.Xsl;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;



namespace DatabaseLayer
{
public class DatabaseLayer
{
private MySqlConnection _connection = null;
private string _connectionString = string.Empty;

public string ConnectionString
{
set { _connectionString = value; }
get { return _connectionString; }
}

public DatabaseLayer()
{
//
// TODO: Add constructor logic here
//
}

public bool OpenConnection()
{
ValidateConnectionString();
_connection = new MySqlConnection();
_connection.ConnectionString = _connectionString;
string exx;
try
{
_connection.Open();
}
catch (Exception ex)
{
exx = ex.Message;
_connection = null;
return false;
}
return true;
}

public bool CloseConnection()
{
bool result = true;
try
{
if (_connection.State == ConnectionState.Open)
{
_connection.Close();
}
}
catch
{
result = false;
}
finally
{
_connection = null;
}
return result;
}


public void ValidateConnectionString()
{
if (0 == _connectionString.Length)
{
throw new Exception("No connection string has been supplied");
}
}

public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray, MySqlParameter outputParam)
{
int result;
MySqlCommand comm = null;
string msg;

result = 0;

try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
outputParam.Direction = ParameterDirection.Output;
comm.Parameters.Add(parameterArray);
result = comm.ExecuteNonQuery();
result = int.Parse(outputParam.Value.ToString());

}
catch (SqlException ex)
{
msg = ex.Message;
}
finally
{
comm = null;
}

// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);

return result;
}

public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray)
{
int result;
MySqlCommand comm = null;
string msg;

result = 0;

try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}

result = comm.ExecuteNonQuery();
}
Eror on this line// catch (Exception ex)
{
and there also erro// msg = ex.Message;
}
finally
{
comm = null;
}

// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);

return result;
}

public object ExecuteScalar(string storedProcedure, MySqlParameter[] parameterArray)
{
object result;
MySqlCommand comm = null;
string msg;

try
{
comm = _connection.CreateCommand();

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}

result = comm.ExecuteScalar();
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }

finally
{
comm = null;
}

//ValidateConnectionString();
//result = SqlHelper.ExecuteScalar(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);

return result;
}

public DataSet ExecuteDataSet(string storedProcedure, MySqlParameter[] parameterArray)
{
DataSet result = new DataSet();
string msg;

MySqlDataAdapter da = null;
da = new MySqlDataAdapter();
MySqlCommand comm = null;

try
{
comm = _connection.CreateCommand();

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
da.SelectCommand = comm;
da.Fill(result, "data");
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }

finally
{
da = null;
comm = null;
}


return result;
}

public MySqlDataReader ExecuteReader(string storedProcedure, MySqlParameter[] parameterArray)
{
MySqlDataReader result = null;
MySqlCommand comm = null;
comm = _connection.CreateCommand();
string msg;

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}

try
{
result = comm.ExecuteReader();
}
catch (Exception ex)
{
msg = ex.Message;
}

finally
{
comm = null;
}

// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);

return result;
}

public DataTable ExecuteDataTable(string storedProcedure, MySqlParameter[] parameterArray)
{


//SqlParameter[] parameter = new SqlParameter[2];
//parameter[0] = new SqlParameter("@userIDN", SqlDbType.Int);
//parameter[1] = new SqlParameter("@activeFlag", SqlDbType.Bit);
//parameter[0].Value = applicationUserIDN;
//parameter[1].Value = activeFlag;

DataTable result = new DataTable();
string msg;

MySqlDataAdapter dataAdapter = null;
dataAdapter = new MySqlDataAdapter();
MySqlCommand comm = null;


//OpenConnection();
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
//comm.Parameters.Add(parameter[0]);
//comm.Parameters.Add(parameter[1]);
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}


try
{
dataAdapter.SelectCommand = comm;
dataAdapter.Fill(result);
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }

finally
{
CloseConnection();
dataAdapter = null;
comm = null;
}

return result;


}

public MySqlDataReader ExecuteReader(string storedProcedure)
{
MySqlDataReader result;
MySqlCommand comm = null;
string msg;
comm = _connection.CreateCommand();

comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;

// foreach (SqlParameter param in parameterArray)
// {
// comm.Parameters.Add(param);
// }

try
{
result = comm.ExecuteReader();
}
// catch (Exception ex)
// {
// msg = ex.Message;
//}

finally
{
comm = null;
}

// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);

return result;
}

}


}



Thanks in Advance
AnswerRe: Only MySqlParameter objects may be stored Pin
Henry Minute1-Apr-09 12:01
Henry Minute1-Apr-09 12:01 
AnswerRe: Only MySqlParameter objects may be stored Pin
Henry Minute2-Apr-09 7:07
Henry Minute2-Apr-09 7:07 
GeneralRe: Only MySqlParameter objects may be stored Pin
Luc Pattyn2-Apr-09 9:01
sitebuilderLuc Pattyn2-Apr-09 9:01 
QuestionNeed sugestion on what font to use with Unicode chars Pin
Christian Wikander1-Apr-09 2:39
Christian Wikander1-Apr-09 2:39 
QuestionRe: Need sugestion on what font to use with Unicode chars Pin
led mike1-Apr-09 5:32
led mike1-Apr-09 5:32 
GeneralRe: Need sugestion on what font to use with Unicode chars Pin
Christian Wikander1-Apr-09 22:36
Christian Wikander1-Apr-09 22:36 
GeneralRe: Need sugestion on what font to use with Unicode chars Pin
led mike10-Apr-09 4:41
led mike10-Apr-09 4:41 
GeneralRe: Need sugestion on what font to use with Unicode chars Pin
Christian Wikander13-Apr-09 21:00
Christian Wikander13-Apr-09 21:00 
Questiongenerate a html help file Pin
soussouprog31-Mar-09 3:10
soussouprog31-Mar-09 3:10 
AnswerRe: generate a html help file Pin
Eddy Vluggen31-Mar-09 3:53
professionalEddy Vluggen31-Mar-09 3:53 
QuestionUpdate MDIChild->dataset(datagridview) when Combobox value in MDIParent changes Pin
paulray31-Mar-09 3:09
paulray31-Mar-09 3:09 
AnswerRe: Update MDIChild->dataset(datagridview) when Combobox value in MDIParent changes Pin
paulray3-Apr-09 3:24
paulray3-Apr-09 3:24 
QuestionHow can i find my installation path during installation.? Pin
RA|-|UL PATEL31-Mar-09 1:37
RA|-|UL PATEL31-Mar-09 1:37 
AnswerRe: How can i find my installation path during installation.? Pin
Eddy Vluggen4-Apr-09 0:49
professionalEddy Vluggen4-Apr-09 0:49 
GeneralRe: How can i find my installation path during installation.? Pin
RA|-|UL PATEL5-Apr-09 17:53
RA|-|UL PATEL5-Apr-09 17:53 
QuestionHow do i call esc key dynamicaly(VB.NET Win forms) Pin
Rajeesh MP30-Mar-09 20:57
Rajeesh MP30-Mar-09 20:57 
AnswerRe: How do i call esc key dynamicaly(VB.NET Win forms) Pin
Colin Angus Mackay31-Mar-09 4:42
Colin Angus Mackay31-Mar-09 4:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.