using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Windows.Forms; using System.Data; namespace DAL { public class dbHelper { SqlConnection SQLConn; string connectionstring; SqlDataAdapter da; public void openconnection() { connectionstring = "Server=GITTWO-PC\\SQL2008R2;Database=emp;User Id=accpac;Password=super1;"; try { SQLConn = new SqlConnection(connectionstring); SQLConn.Open(); } catch(Exception ex) { MessageBox.Show(" Error Connecting to database! - " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } public void closeconnection() { SQLConn.Close(); } public DataTable getdt(string query) { openconnection(); da = new SqlDataAdapter(query, SQLConn); DataTable dt; da.Fill(dt); closeconnection(); return dt; } public Boolean executequery(String query) { openconnection(); SqlCommand com =new SqlCommand(query, SQLConn); com.ExecuteNonQuery(); closeconnection(); return true; } } }
DataTable dt;
DataTable dt = new DataTable();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)