Hej,
Her et hurtigt lille eksempel - Måske kan det få dig på vej.
public class Database
{
private string ConnString = string.Empty;
public Database(string Source, string DatabaseNavn){
StringBuilder db = new StringBuilder();
db.Append("Data Source=");
db.Append(Source??System.Environment.MachineName.ToString());
db.Append("\\\\SQLEXPRESS;");
db.Append("Initial Catalog=");
db.Append(DatabaseNavn??"dbo"+";");
db.Append("Integrated Security=True");
ConnString = db.ToString() );
}
public DataSet hentData(){
DataSet ds = new DataSet();
using (SqlConnection conn = new SqlConnection connnString))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM TABEL", conn)) {
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds, "enTabel");
}
}
return ds;
}