473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

data access question in asp.net 2.0

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("testConnec tionString").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>

Dec 22 '06 #1
2 1048
select * from tablename where username=@username

Then, if the dataset's table has even 1 row, tell them it's already taken,
and exit out of the sub - but you probably shouldn't have it in the PageLoad
event anyway - have it in another sub and use it whenever someone logs in.

Even still - have you looked into the ASP.Net 2.0 login controls?

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"weiwei" <we*********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
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("testConnec tionString").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>

Dec 24 '06 #2
thank you very much, I will let you know what is my result
David Wier wrote:
select * from tablename where username=@username

Then, if the dataset's table has even 1 row, tell them it's already taken,
and exit out of the sub - but you probably shouldn't have it in the PageLoad
event anyway - have it in another sub and use it whenever someone logs in.

Even still - have you looked into the ASP.Net 2.0 login controls?

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"weiwei" <we*********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
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("testConnec tionString").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>
Dec 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
9
by: Tony Lee | last post by:
Some time a ago, on this newsgroup the following comments were made in recommending good references for Access (2003) >I used to recommend Dr. Rick Dobson's, "Programming Access <version>" for...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.