|
-
May 24th, 2004, 05:57 AM
#1
A few simple ADO.NET questions [Resolved]
Going through the book, studying as usual, I was instructed that when I want to use the SQLDataAdapter, SQLConnection objects, and generate a DataSet object, and then bind my control (textbox, datagrid, whatever) to it to get the value.
My first question is:
Is this the way most of you do it? Or do you prefer doing it through code?
I did it the way described above, and saw that it generated a lot of code. So, my VB6-remnant brain assumed that using these objects to connect to a database would be as inefficient as using the ADODC control in VB6 (You guys remember that one? )
So, I tried to do it through code. Here is what I came up with so far:
VB Code:
Dim scSqlConn As New SqlConnection
scSqlConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=NorthWind;uid=sa;pwd=;" & _
"Integrated Security=SSPI"
scSqlConn.Open()
'data set, data adapter
Dim dsDataSet As New DataSet
Dim daDataAdapter As New SqlDataAdapter
Dim cmdSELECTCOMMAND As New SqlCommand
cmdSELECTCOMMAND.CommandText = "SELECT * FROM Customers;"
cmdSELECTCOMMAND.Connection = scSqlConn
daDataAdapter.SelectCommand = cmdSELECTCOMMAND
daDataAdapter.Fill(dsDataSet, "Customers")
Second question:
Am I doing it right? Am I missing something?
Third question:
I am simply trying to set a Textbox1.Text property to a value in the table.
In VB6, this was:
VB Code:
TextBox1.Text = Objrs.Fields(0).Value
I can't figure out how to do that in ADO.NET. Any ideas what I should do?
Thanks.
Last edited by mendhak; May 24th, 2004 at 11:28 AM.
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
|