•
•
•
•
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
![]() |
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?
Many thanks for your help. This is totally frustrating.
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.
...well I solved that one.
The necessary code was simply this:
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.
The necessary code was simply this:
While dataReader.Read()
if dataReader("Username") = txtUsername.Text then
label1.Text = "Username is already taken!"
end if
End WhileThis is why I hate computers.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- transfer data from an asp .net page into a javasscript script (ASP.NET)
- ASP.NET and Mozilla - Issues! (ASP.NET)
- Using Visual Fox Pro data tables in asp.net application (ASP.NET)
- asp.net tutorial (ASP)
- ASP.NET: Context.Items.Add question (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: ASP, Java and XML-RPC
- Next Thread: asp sales report


Linear Mode