jeg kan godt lave en Select * og det virker men , kan man ikke lave en mere gennerel , hvor man også kan smide en update , Delete etc.
PT , bruger jeg denne til Read
public static ArrayList reader (string tabel) //man kan kun angive hele tabeller ,da where også videre kan laves ved sortering etc.
{
//create the database connection OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\skytte\\skytte.mdb");
//create the command object and store the sql query OleDbCommand aCommand = new OleDbCommand(tabel, aConnection); ArrayList list = new ArrayList(); try { aConnection.Open();
//create the datareader object to connect to table OleDbDataReader aReader = aCommand.ExecuteReader(); //Console.WriteLine("This is the returned data from table"); int t;
int n = aReader.FieldCount; string line; //Iterate throuth the database while(aReader.Read()) { line =""; t = 0; //MessageBox.Show (aReader.GetString(1)); while (n != t) { if (line == "") { line = (aReader.GetValue(t).ToString()); } else { line = line + "," + (aReader.GetValue(t).ToString()); } t++;
} list.Add(line); }
//close the reader aReader.Close();
//close the connection Its important. aConnection.Close();
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.