|
-
October 8th, 2002, 01:30 PM
#1
How to do this in a better way%
It might not be the best way to navigate through a recordset, but is there an actual way to do the following code better?
Code:
private void button1_Click(object sender, System.EventArgs e)
{
ADODB.Connection objConnection = new ADODB.ConnectionClass();
ADODB.Recordset rsData = new ADODB.RecordsetClass();
objConnection.Open("Provider=SQLOLEDB;User ID=daing;Password=daing;Initial Catalog=D42DAIng;Data Source=HERCULES", "daing", "daing", 0);
rsData.Open("select * from t016_achat", objConnection, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);
while (!rsData.EOF)
{
MessageBox.Show(rsData.Fields["CleUniqueA"].Value.ToString());
rsData.MoveNext();
}
}
Funny, I found no information at all on the RecordsetClass, so I guess this is not the way to proceed!!
-
October 31st, 2002, 06:47 AM
#2
Try adding a Dataset to your project and fill it like this.
SqlDataAdapter1.Fill(dataSet1);
And after that you can access the data from there with this:
string name;
name = (string) dataSet1.Tables["blahblah"]["name"];
MessageBox.Show(this,name);
WM.
What about weapons of mass construction?
-
October 31st, 2002, 10:40 AM
#3
Any particular reason you're not using ADO.NET?
-
October 31st, 2002, 01:24 PM
#4
No particular reason 
But I agree it's smarter to use ADO.NET
WM.
What about weapons of mass construction?
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
|