User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 429,789 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,836 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 4848 | Replies: 1
Reply
Join Date: Dec 2004
Posts: 2
Reputation: fortheloveof is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
fortheloveof's Avatar
fortheloveof fortheloveof is offline Offline
Newbie Poster

ASP.NET, referring to a DataSet within script

  #1  
Dec 28th, 2004
I am using ASP.NET, and the ASP.NET WebMatrix program, latest version. I am writing a page that is supposed to check the username someone has entered into a textbox against the list of users from the database, so that two people can't have the same username. Simple, right? Not when you're me.

I know what I'd like to do, I just have no idea how to write the following in ASP.NET. This is the pseudo-code for it.
"If txtUserName.Text = Currently Selected Record.Username then"

I can put a <asp:repeater> in the code and use <%#Container.DataItem("Username")%> to print the Username which is great, but that doesn't work within the <script> tags at the top of the page. I just want to know how to refer to the records I've just loaded. What is it called?

Also, what is the difference between a dataSet and a dataReader?

Function GetCustomerList() As System.Data.IDataReader
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & server.mappath("db\super.mdb")
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
        Dim strUN

        Dim queryString As String = "SELECT Customer.Username FROM Customer"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
         dbCommand.CommandText = queryString
         dbCommand.Connection = dbConnection

         dbConnection.Open
         Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

         Return dataReader
End Function

Sub cmdSubmit_Click(sender As Object, e As EventArgs)
        GetCustomerList()
        If txtUserName.Text = !!!WHAT! WHAT do I have to do here!!! Then
              lblUsed.Text = "That username is in use. Please choose another."
        else
              lblUsed.Text = "OK"
        end if
End Sub

Many thanks for your help. This is totally frustrating.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 2
Reputation: fortheloveof is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
fortheloveof's Avatar
fortheloveof fortheloveof is offline Offline
Newbie Poster

Re: ASP.NET, referring to a DataSet within script

  #2  
Dec 28th, 2004
...well I solved that one.

The necessary code was simply this:
             While dataReader.Read()
                 if dataReader("Username") = txtUsername.Text then
                     label1.Text = "Username is already taken!"
                 end if
             End While
This .Read() fiasco apparently replaced the old .MoveNext from regular ASP. When there are items left, .Read() will return "True". Otherwise, i.e. when there are no more records, it will return "False"... hence the while loop.

This is why I hate computers.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 4:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC