| | |
ASP.NET, referring to a DataSet within script
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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?
ASP Syntax (Toggle Plain Text)
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:
ASP Syntax (Toggle Plain Text)
While dataReader.Read() if dataReader("Username") = txtUsername.Text then label1.Text = "Username is already taken!" end if End While
This is why I hate computers.
![]() |
Similar Threads
- ASP.Net perm full time programmer wanted (Web Development Job Offers)
- Front-End Developer with ASP.net needed!!! (Web Development Job Offers)
- Experience ASP.net with C# developer needed!! (Web Development Job Offers)
- ASP.Net / C# Web Developer (Web Development Job Offers)
- transfer data from an asp .net page into a javasscript script (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: ASP, Java and XML-RPC
- Next Thread: asp sales report
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





