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.