For a class project we have to use ASP.net with VB code to do a user login, I've followed the steps pretty closely, but it seems I'm missing something. when
Dim strSQL As String = "SELECT * FROM [" & TABLE_NAME & "]"
and
Dim dv As DataView = ds.Tables(TABLE_NAME).DefaultView
come up "TABLE_NAME" is underlined as an undeclared object. According to my understanding this should simply pass in the name of the table I am using? I am rather confused as to what I am doing wrong here. Any help would be appreciated, here is the entire code page. I am sure I am simply making some amatuer mistake.
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Partial Class index
Inherits System.Web.UI.Page
Dim con As New SqlConnection("Server = tcp:kw0ythb209.database.windows.net,1433;Database=dynamicSite;User [email protected];Password=haruhi23;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;")
Dim da As New SqlDataAdapter()
Dim cmd As New SqlCommand()
Dim ds As New DataSet()
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim strSQL As String = "SELECT * FROM [" & TABLE_NAME & "]"
Try
con.Open()
da.SelectCommand = New SqlCommand(strSQL, con)
da.Fill(ds, "dynamicSite")
con.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
' Get the dataview from the table
' alternative to: ds.Tables(0)
' A dataview allows sorting
Dim dv As DataView = ds.Tables(TABLE_NAME).DefaultView
dv.Sort = "name"
Dim searchString As String = txtUser.Text
Dim myIndex As Integer = dv.Find(searchString)
If myIndex <> -1 Then
dv.Sort = "pass"
Dim searchString2 As String = txtPass.Text
Dim myIndex2 As Integer = dv.Find(searchString)
If myIndex2 <> -1 Then
Response.Redirect("myDataView.aspx")
End If
Else
End If
End Sub