|
-
March 16th, 2012, 12:15 PM
#1
HELP! Question about C#
I am creating a simple DBA Application but I am a newbie having trouble determining how to know if the connection is open from a different method. This is part of my code can anyone help me in how to
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
namespace Connect2
{
class ConnectInfo
{
public string DatabaseName { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string SourceIP { get; set; }
public string Query { get; set; }
public ConnectInfo(string dbaname, string username, string password, string sourceip, string query)
{
DatabaseName = dbaname;
Username = username;
Password = password;
SourceIP = sourceip;
Query = query;
}
public void Connect()
{
string connectionString;
connectionString = "provider=MSDAORA;data source={2};user id={1};password={0}" +DatabaseName +Password +SourceIP;
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
myOleDbConnection.Open();
}
public void ExecuteQuery()
{
// How can i get that myOledbConnection to this method from connect method?
SqlCommand command = new SqlCommand(query, myOleDbConnection);
command.ExecuteNonQuery();
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|