You are not logged in.

wcf.regNote.message

torkel

Beginner

  • "torkel" started this thread

Posts: 8

  • Send private message

1

Saturday, July 23rd 2005, 3:24pm

Abfrage auf ein DataSet

Hallo

kann mir jemand sagen, wie ich eine Abfrage auf eine DataSet durchführen kann?

ich habe eine Labelbox mit "Preis" und eine TextBOX wo ich eine nummer eingeben kann. Das heisst, ich gebe z.b 10 ein, dann sollte die Abrage bei Index 10 in der Tabelle nachschauen und den Preis von diesem Artikel in der LabelBox ausgeben.

wie setze ich einen solchen befehl ab?

thanxx

Avelyn

Trainee

Posts: 78

Location: Österreich

  • Send private message

2

Sunday, October 23rd 2005, 2:55pm

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();
 }
"Beware of bugs in the above code; I have only proved it correct, not tried it" - Donald Knuth

wcf.user.socialbookmarks.titel