|
-
June 24th, 2006, 03:32 PM
#1
Learning Problems with ADO.Net
Hi there guys, I'm having major problems trying to distinguish which ASP.Net 2.0 objects to use for data access, whilst avoiding n-tier wizard generated, web-control powered tidal waves of code
For example, u remember the old ADO 2.x ...
C.Open "connection string"
RS.ActiveConnection = C
RS.Open "SELECT * FROM tblData"
RS.Edit
RS("somefield") = "new data"
RS.Update
RS.Close
Is there an equivalent to the old way? I only need to validate usernames/passwords and don't have the time to be messing with stored procedures.
-
July 14th, 2006, 10:27 AM
#2
Re: Learning Problems with ADO.Net
Daniela
******
I would love to change the world, but they won't give me the source code
-
July 25th, 2006, 01:43 AM
#3
Re: Learning Problems with ADO.Net
Daniela,
I will read through those links you suggest.
I am still thinking VB6 and RecordSet processing.
One process I will be programming will involve the user entering parameters which will determine which SQL Server 2000 Database to read.
In other words, I will need to take in a paramenter and set up VB.net to read a specific Database.
The project has multiple databases ( all with the same tables but representing different business units).
Another requirement will be to read all databases as thought they are one.
Is there a facility to link up multiple like databases ?
Hopefully, there is an easy programming solution, or a sql server feature to make this possible without repeative processing and intermmediate data storage control.
Thanks
TT
-
July 26th, 2006, 12:20 AM
#4
Re: Learning Problems with ADO.Net
I should have added the approach I am taking to learn and develop a project. It is web form based.
In the early days of my VB6 learnings, I worked with bound controls off the editor.
Then I found out that ADO was more a programming control, where you defined a connection, command and recordset.
From then I used the recordset results to do the specific data processing within my programs.
Is this the same for Ado.net
I am currently working off a text book that illustrates how to
-connect to a db
-add a connection to a form
-work with data tables
-work with data columns
-work with data rows
-bind a control on a form.
Am I following a less powerful approach to generating program solutions using ADO.net
I am struggling to locate where I can enter the SQL commands to generate data results within the Web Form Code.
For instance I have a column in my table called SRECTYPE, I want to count how many of each srectype code is on the table. Summing each distinct row.
So I have one table and one column to work with, and the column contains 3 codes.
The sql I want to use is
select distinct srectype, count(srectype)
from conthist
group by srectype
TT
-
July 30th, 2006, 10:03 AM
#5
Re: Learning Problems with ADO.Net
T2T2,
there are 2 steps you could take. If you need to store the result sets of your query or if the result of the query is large, you should use the following approach and store the result of the query in a dataset:
(I will write the code in C# since I haven't done vb programming in ages but you should be able to easily change it to VB)
PHP Code:
DataSet dsData = new Dataset(); using(SqlConnection sqlConn = new SqlConnection()) { sqlConn.ConnectionString = "your connection str"; using(SqlDataAdapter dbAdapter = new SqlDataAdapter()) { dbAdapter.SelectCommand = new SqlCommand(); dbAdapter.SelectCommand.CommandText = "Your sql query"; dbAdapter.SelectCommand.Connection = sqlConn; dbAdapter.Fill(dsData); } }
If you need to read just a few values, you should use a SqlDataReader
PHP Code:
string readValue; using(SqlConnection sqlConn = new SqlConnection()) { using(SqlCommand sqlCmd = new SqlCommand()) { sqlCmd.CommandText = "Your Query"; sqlCmd.Connection = sqlConn; sqlConn.Open(); using(SqlDataReader reader = sqlCmd.ExecuteReader()) { while(reader.Read()) { readValue = reader.GetString(0); } } } }
If my posts have helped you, please rate them. Ratings give me that warm, fuzzy feeling of having helped someone out 
-
July 30th, 2006, 10:34 PM
#6
Re: Learning Problems with ADO.Net
Hedge fund,
I like your user id name.
I am only starting to appreciate (understand) datasets.
Your examples actually illustrated to me how sql can be employed with adaptors, which I will now attempt to use in my project.
I am also starting to see what others like about .net
Thanks.
TT
-
July 31st, 2006, 08:56 PM
#7
Re: Learning Problems with ADO.Net
 Originally Posted by T2T2
Hedge fund,
I like your user id name.
Thanks 
As for what can be done with ADO.net, I have only scratched the surface with the examples I have provided for you. Microsoft has done an absolutely wonderful job coming up with such a robust and useful library. The more you program with it, the harder it will be to go back to other languages such as c++ where you may have to spend hours to do what c# does in a few lines of code.
If my posts have helped you, please rate them. Ratings give me that warm, fuzzy feeling of having helped someone out 
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
|