W
weiwei
Hi,
I have a question regarding data access, here is my scenario, when a
user create username, that username is check against
username table, if new request username is existed already, then return
it to user who originally requested. if that username
is not existed previously, then added it into the database. in
classical asp, I can do that do while...loop + if else
statement. now I am trying to do the .net version, and I am using
visual studio 2005 professional edition.
how can I checking each record in the db table in asp.net? below is my
current code.
thanks in advance!
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="datatest.aspx.vb" Inherits="datatest" %>
<script runat="server">
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
'my connectionstring is already configured in web.config
Dim myConnection As String =
ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString
Dim strSQL As String = "Select * FROM test"
Dim Connection As New
Data.SqlClient.SqlConnection(myConnection)
Dim myCommand As New Data.SqlClient.SqlCommand(strSQL,
Connection)
Connection.Open()
myCommand.ExecuteNonQuery()
Connection.Close()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<form id="Form1" runat="server">
</form>
</body>
</html>
I have a question regarding data access, here is my scenario, when a
user create username, that username is check against
username table, if new request username is existed already, then return
it to user who originally requested. if that username
is not existed previously, then added it into the database. in
classical asp, I can do that do while...loop + if else
statement. now I am trying to do the .net version, and I am using
visual studio 2005 professional edition.
how can I checking each record in the db table in asp.net? below is my
current code.
thanks in advance!
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="datatest.aspx.vb" Inherits="datatest" %>
<script runat="server">
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
'my connectionstring is already configured in web.config
Dim myConnection As String =
ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString
Dim strSQL As String = "Select * FROM test"
Dim Connection As New
Data.SqlClient.SqlConnection(myConnection)
Dim myCommand As New Data.SqlClient.SqlCommand(strSQL,
Connection)
Connection.Open()
myCommand.ExecuteNonQuery()
Connection.Close()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<form id="Form1" runat="server">
</form>
</body>
</html>