Results 1 to 8 of 8

Thread: SQL in DataSet? (Solved)

  1. #1

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192

    SQL in DataSet? (Solved)

    Hello... I just wondered if DataSet here on C# is like the Data set in Visual Basic... If so...

    Could you please give me an example of a SQL query on a C# DataSet?

    (Yes, I know SQL, but I am curious to know how to apply it on C#) Thanks in advance!
    Last edited by Tec-Nico; May 28th, 2003 at 01:18 AM.
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Not sure what you mean... You want to query a dataset like it was a database table?

    If so, I am not sure how to do that directly, but you could use a dataview object to find what your looking for in the dataset.

  3. #3

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    I want something similar to:

    VB Code:
    1. Dim myDB As Object
    2. Set myDB = Workspaces(0).OpenDatabase(Resultados.DBMaterial.DatabaseName)
    3.  
    4. Dim MySQL As String
    5. MySQL = "SELECT * FROM Material WHERE ID = givenID"
    6.  
    7. Dim Rs As Recordset
    8. Set Rs = myDB.OpenRecordset(MySQL)
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Tec-Nico
    Hello... I just wondered if DataSet here on C# is like the Data set in Visual Basic... If so...
    Dataset concept in ADO.NET is completely different than VB6's (since there wasn't disconnected mode ..etc).

    Code:
    string sqlstr ="SELECT * FROM MyTable";
    System.Data.OleDb.OleDbConnection conn =new OleDbConnection ("connecting settings");
    DataSet ds=new DataSet() ;
    conn.Open();
    System.Data.OleDb.OleDbDataAdapter myadapter =new OleDbDataAdapter (sqlstr,conn);
    myadapter.Fill (ds,yourtable);
    'Here we get the first row in the dataset 
    MessageBox.Show (ds.Tables[yourtable].Rows[0]);

  5. #5

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Thanks, I also found another way to access Databases and all was going right until I tried to use a SQL statement and I tried to delete a certain row...

    I am using DataSet... Isn't there a RecordSet like on VB6?

    It is I have an XML File and I am trying to manage this as objects (Yes, I was asked by my professor to do this: An object Database)

    So I open a file in a constructor of my Dictionary of Objects and then I load the database if the XML file exists, I create an Object for every register in the DB and when they add something to this dictionary, I add a row to the DataBase and I save the XML file. But my problem is when I want to Update a certain Item or I want to Remove a certain Item... Both need a SQL query... And I don't know how to remove that item from the Database...

    Any help or suggestions?
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This should answer your questions tremendously .
    http://www.dotnetextreme.com/code/BasicAdo.asp

  7. #7

    Thread Starter
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    Thanks, Pirate.. This is just what I needed
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width