using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace Sulution.Framework.Core
{
public class SQLServerConnector {
SqlConnection con;
SqlCommand cmd = null;
SqlDataReader reader = null;
public SQLServerConnector()
{
con = new SqlConnection();
}
public void SetParams( string server,
string user,
string pwd)
{ con.ConnectionString = "User ID=" + user + ";" +
"password=" + pwd + ";server=" + server + ";" +
"connection timeout=30";
}
public bool Connect()
{
try
{
con.Open();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return false;
}
return true;
}
public void Close()
{
con.Close();
}
public SqlDataReader ExecQuery(string text)
{
cmd = new SqlCommand(text, con);
reader = cmd.ExecuteReader();
return reader;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace Sulution.Framework.Core
{
public class SQLServerConnector {
SqlConnection con;
SqlCommand cmd = null;
SqlDataReader reader = null;
public SQLServerConnector()
{
con = new SqlConnection();
}
public void SetParams( string server,
string user,
string pwd)
{ con.ConnectionString = "User ID=" + user + ";" +
"password=" + pwd + ";server=" + server + ";" +
"connection timeout=30";
}
public bool Connect()
{
try
{
con.Open();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return false;
}
return true;
}
public void Close()
{
con.Close();
}
public SqlDataReader ExecQuery(string text)
{
cmd = new SqlCommand(text, con);
reader = cmd.ExecuteReader();
return reader;
}
}
}
Комментариев нет:
Отправить комментарий