|
-
May 19th, 2003, 03:05 PM
#1
Thread Starter
Frenzied Member
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
-
May 19th, 2003, 03:51 PM
#2
PowerPoster
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.
-
May 19th, 2003, 05:59 PM
#3
Thread Starter
Frenzied Member
I want something similar to:
VB Code:
Dim myDB As Object
Set myDB = Workspaces(0).OpenDatabase(Resultados.DBMaterial.DatabaseName)
Dim MySQL As String
MySQL = "SELECT * FROM Material WHERE ID = givenID"
Dim Rs As Recordset
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
-
May 20th, 2003, 02:40 AM
#4
Sleep mode
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]);
-
May 20th, 2003, 10:05 AM
#5
Thread Starter
Frenzied Member
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
-
May 20th, 2003, 10:14 AM
#6
Sleep mode
This should answer your questions tremendously .
http://www.dotnetextreme.com/code/BasicAdo.asp
-
May 20th, 2003, 01:47 PM
#7
Thread Starter
Frenzied Member
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
-
May 20th, 2003, 03:16 PM
#8
Sleep mode
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|