A
Ayo Ogundahunsi
Hi,
I have this method - GetConnection in a different namespace, DLL so that i
can reuse it.
namespace MyCompany.ClassLibrary.Data
{
/// <summary>
/// This Class contains database, connection, and SQL Server related
methods and properties.
/// </summary>
public class Connect
{
.....
public SqlConnection GetConnection(string connectionString)
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
return connection;
}
In seperate Clase i have this :
private void grdSchedule_Navigate(object sender,
System.Windows.Forms.NavigateEventArgs ne)
{
Connect connect = new Connect();
SqlConnection connection = null;
connection = connect.GetConnection(connectionString);
}
However, i get the compile error: Cannot implicitly convert type 'object'
to 'System.Data.SqlClient.SqlConnection' on the line:
connection = connect.GetConnection(connectionString);
I'll appreciate any help on how to resolve this.
Thanks,
Ayo.
I have this method - GetConnection in a different namespace, DLL so that i
can reuse it.
namespace MyCompany.ClassLibrary.Data
{
/// <summary>
/// This Class contains database, connection, and SQL Server related
methods and properties.
/// </summary>
public class Connect
{
.....
public SqlConnection GetConnection(string connectionString)
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
return connection;
}
In seperate Clase i have this :
private void grdSchedule_Navigate(object sender,
System.Windows.Forms.NavigateEventArgs ne)
{
Connect connect = new Connect();
SqlConnection connection = null;
connection = connect.GetConnection(connectionString);
}
However, i get the compile error: Cannot implicitly convert type 'object'
to 'System.Data.SqlClient.SqlConnection' on the line:
connection = connect.GetConnection(connectionString);
I'll appreciate any help on how to resolve this.
Thanks,
Ayo.