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. 2 1914
The only thing that i can think of is that there is some other Connect
class in your references.
try this
MyCompany.ClassLibrary.Data.Connect connect = new
MyCompany.ClassLibrary.Data.Connect();
Sijin Joseph http://www.indiangeek.net http://weblogs.asp.net/sjoseph
Ayo Ogundahunsi wrote: 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.
Hi Sijin,
I just tried your suggestion and still got the same compile error.
"connect.GetConnection" was highlighted when you double click on the error.
Ayo.
"Sijin Joseph" <si***************@hotmail.com> wrote in message
news:eg**************@TK2MSFTNGP15.phx.gbl... The only thing that i can think of is that there is some other Connect class in your references.
try this
MyCompany.ClassLibrary.Data.Connect connect = new MyCompany.ClassLibrary.Data.Connect();
Sijin Joseph http://www.indiangeek.net http://weblogs.asp.net/sjoseph Ayo Ogundahunsi wrote: 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven Bethard |
last post by:
In the "empty classes as c structs?" thread, we've been talking in some
detail about my proposed "generic objects" PEP. Based on a number of
suggestions, I'm thinking more and more that instead of...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have...
|
by: Matt |
last post by:
I want to know if "int" is a primitive type, or an object?
For example, the following two approaches yield the same result.
> int t1 = int.Parse(TextBox2.Text); //method 1
> int t2 =...
|
by: Arpan |
last post by:
The .NET Framework 2.0 documentation states that
An Object variable always holds a pointer to the data, never the data
itself.
Now w.r.t. the following ASP.NET code snippet, can someone please...
|
by: phpCodeHead |
last post by:
Code which should allow my constructor to accept arguments:
<?php
class Person {
function __construct($name)
{
$this->name = $name;
}
function getName()
|
by: santoshsri |
last post by:
Hello,
I have written a Console application in C#, it basically imports data from tab delimited text files and save in SQl Server database. I am converting currency format of Mortgage value into...
|
by: Bill H |
last post by:
Hi
I have some perl code that lets me request different things, images,
audio, etc and it will output the correct mime type header and
"stream" the file to a browser (instead of a hard link to...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: tonytech08 |
last post by:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).
What I don't like about the C++ object...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |