Man kann auf ein DataSet keine queries absetzen. Ein DataSet ist nur ein Daten-Cache im Arbeitspeicher von einem Query.
Woher holst du dir den die Daten? MySQL? MSSQL? Aus einer Access MDB?
Hier ist ein kleines Beispiel für MS-SQL:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public void InsertRow(string myConnectionString)
{
// If the connection string is null, use a default.
if(myConnectionString == "")
{
myConnectionString = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;";
}
SqlConnection myConnection = new SqlConnection(myConnectionString);
string myInsertQuery = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')";
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
}
|