•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 375,171 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,129 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 142981 | Replies: 74 | Solved
![]() |
•
•
Join Date: Feb 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 1
I'm using SQLServer 7.0
My strConnection in web.config
<appSettings>
<add key="connString" value="server=myDBServer;uid=myid;pwd=myPass;database=myDB" />
</appSettings>
For SQL, I common out the Access thing, and use the syntax for SQL as you suggested:
' First is the Connection Object for an Access DB
' Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
' This is the Connections Object for an SQL DB
SqlConnection(ConfigurationSettings.AppSettings("connString"))
and I got the error here saying that SqlConnection was not declared.
I thought the import we need for SQLServer is Imports System.Data.SqlClient
not Imports System.Data.OleDb
My strConnection in web.config
<appSettings>
<add key="connString" value="server=myDBServer;uid=myid;pwd=myPass;database=myDB" />
</appSettings>
For SQL, I common out the Access thing, and use the syntax for SQL as you suggested:
' First is the Connection Object for an Access DB
' Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
' This is the Connections Object for an SQL DB
SqlConnection(ConfigurationSettings.AppSettings("connString"))
and I got the error here saying that SqlConnection was not declared.
I thought the import we need for SQLServer is Imports System.Data.SqlClient
not Imports System.Data.OleDb
Hi there Kendel,
You are correct about the import, and if you recall on the Tutorial in the comments I state that very thing:
and here futher down in the same post
And further down in the post I state the following as well :
And I just stated a notable change to the strConn in the web.config for SQL 7.0 or greater today.
Hope this helps.
With a regards to basic errors like "something xyz is not declared", and as a means for the me better help everyone better, I would appreciate it if you try to investigate the errors you are getting a little better before posting them here. These are generally just a copy and pastee, coding or syntax error, and a fairly easy to fix once you review your code. Hard and fast rules of .Net Framework requires you to DECLARE all variables!
The SQL version of this is still being worked on, and I will have a step by step guide completed before long, just extremely busy at the moments building an Oracle based system and it is very time consuming.
But I will try to answer any questions you have on this thread or the new thread whenever I can. So keep the questions coming!
Happy coding

You are correct about the import, and if you recall on the Tutorial in the comments I state that very thing:
•
•
•
•
"Ok remember that you require the creation of a connection object inorder to access the SQL Database. The basics for the connection string (the means of creating this connection object) is;
Imports System.Data.SqlClient
...
Dim oSQLConn As SqlConnection = New SqlConnection()
....
"
•
•
•
•
The updated heading to all ASP.Net Page Code Behinds (still using VB.Net):
' ||||| This is the Connections Object for an SQL DB Dim MyConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
•
•
•
•
The updated heading to all ASP.Net Page Code Behinds (still using VB.Net):
Imports System.Web.Security ' ||||| Required Class for Authentication Imports System.Data ' ||||| DB Accessing Import Imports System.Data.SqlClient Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||
New Web.Config (partial code only, not the whole file)
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- ||||| Application Settings ||||| --> <appSettings> <add key="strConn" value="Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;"/> </appSettings> <system.web> ...
•
•
•
•
The SQL Server .NET Data Provider allows you to connect to a Microsoft SQL Server 7.0 or 2000 database. For Microsoft SQL Server 6.5 or earlier, use the OLE DB .NET Data Provider with the "SQL Server OLE DB Provider" (SQLOLEDB).
Note: The SQL Server .NET Data Provider knows which data provider it is. Hence the "provider=" part of the connection string is not needed.
With a regards to basic errors like "something xyz is not declared", and as a means for the me better help everyone better, I would appreciate it if you try to investigate the errors you are getting a little better before posting them here. These are generally just a copy and pastee, coding or syntax error, and a fairly easy to fix once you review your code. Hard and fast rules of .Net Framework requires you to DECLARE all variables!
The SQL version of this is still being worked on, and I will have a step by step guide completed before long, just extremely busy at the moments building an Oracle based system and it is very time consuming.
But I will try to answer any questions you have on this thread or the new thread whenever I can. So keep the questions coming!
Happy coding

•
•
•
•
Originally Posted by Kendel
I'm using SQLServer 7.0
My strConnection in web.config
<appSettings>
<add key="connString" value="server=myDBServer;uid=myid;pwd=myPass;database=myDB" />
</appSettings>
For SQL, I common out the Access thing, and use the syntax for SQL as you suggested:
' First is the Connection Object for an Access DB
' Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
' This is the Connections Object for an SQL DB
SqlConnection(ConfigurationSettings.AppSettings("connString"))
and I got the error here saying that SqlConnection was not declared.
I thought the import we need for SQLServer is Imports System.Data.SqlClient
not Imports System.Data.OleDb
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Mar 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 1
I just try to create my own member.db and run the sp_ValidateUser which can return 1 but the asp.net just always pass to the
Catch ex As Exception
lblMessage.Text = "Error Connecting to Database!"
when it reach the below statement
objReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
Please help....
Catch ex As Exception
lblMessage.Text = "Error Connecting to Database!"
when it reach the below statement
objReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
Please help....
How do you know it is that line of code that is the source of the error? What is the error message.
See new link for the updated code!
New more details to solve your problem please!
See new link for the updated code!
New more details to solve your problem please!
•
•
•
•
Originally Posted by gbgykkcci88888
I just try to create my own member.db and run the sp_ValidateUser which can return 1 but the asp.net just always pass to the
Catch ex As Exception
lblMessage.Text = "Error Connecting to Database!"
when it reach the below statement
objReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
Please help....
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Feb 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 1
Thanks for your help and being so patient with me. This is my very first attempt to work with .net so please excuse me for my dumb question. I'm still having a hard time to convert your code to work with SQL Server. Thanks.
Answer : LINK
•
•
•
•
Originally Posted by Kendel
Thanks for your help and being so patient with me. This is my very first attempt to work with .net so please excuse me for my dumb question. I'm still having a hard time to convert your code to work with SQL Server. Thanks.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Feb 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 1
Hello, i'm really new in this dot net. I would like to try the sample..
In the case cmdSubmit Button
can i know how the login been authenticate in the default.aspx page?
thank u for your generous help..
In the case cmdSubmit Button
•
•
•
•
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) ' ||||| default.aspx Page!
can i know how the login been authenticate in the default.aspx page?
thank u for your generous help..
Last edited by mimyanun : Mar 11th, 2005 at 10:24 pm. Reason: wan to detele
It is not being authenticated in the Default.aspx page, it is being authenticated against the database, and the Redirect is sending the user on a successful login to the default.aspx page (which is the "default" page ASP.net sends you to following a RedirectFromLogin).
The function of the FormsAuthentication Class; RedirectFromLoginPage is overrided, and can accept 2 or 3 variables, depending on the one you are using. I am using the 2 arguement overrided function. Which excepts the userName as a String, and createPersistentCookie as a Boolean.
So I have passed the userName in via txtUserName.Text, and said False to creating a persistentCookie. This allows you to say set a greeting to the specific user, or whatever else you may want to do with this passed in value.
Hope this helps!
The function of the FormsAuthentication Class; RedirectFromLoginPage is overrided, and can accept 2 or 3 variables, depending on the one you are using. I am using the 2 arguement overrided function. Which excepts the userName as a String, and createPersistentCookie as a Boolean.
So I have passed the userName in via txtUserName.Text, and said False to creating a persistentCookie. This allows you to say set a greeting to the specific user, or whatever else you may want to do with this passed in value.
Hope this helps!
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Apr 2005
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 1
hi in your code u make a function but whats it s parameters plz mail me so i do it
i m new in asp.net
i m new in asp.net
Ok, please be a little more specific.
Every function in the code takes a parameter, so what function are you refering to?
Function syntax: Function <name> (<parameters>)<return datatype of function>
Please BE MORE specific.
Every function in the code takes a parameter, so what function are you refering to?
Function syntax: Function <name> (<parameters>)<return datatype of function>
Please BE MORE specific.
•
•
•
•
Originally Posted by Qbit75
hi in your code u make a function but whats it s parameters plz mail me so i do it
i m new in asp.net
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
Other Threads in the ASP.NET Forum
- Previous Thread: ASP.Net Directory Problems
- Next Thread: Ready to take up a challenge

Linear Mode