954,116 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I'm using SQLServer 7.0

My strConnection in web.config

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

Kendel
Newbie Poster
12 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

Hi there Kendel,

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()
....

" and here futher down in the same post 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 <strong>SqlConnection </strong>= New SqlConnection(ConfigurationSettings.AppSettings("strConn"))

And further down in the post I state the following as well : 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
  <strong>Imports System.Data.SqlClient</strong>
  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> 
   <strong><add key="strConn" value="Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;"/></strong>  
  </appSettings> 
  <system.web>
  ...

And I just stated a notable change to the strConn in the web.config for SQL 7.0 or greater today. 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
.
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

:cool:
I'm using SQLServer 7.0

My strConnection in web.config


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

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

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....

gbgykkcci88888
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 1
 

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!


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....

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

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.

Kendel
Newbie Poster
12 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

Answer : LINK



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.

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

Hello, i'm really new in this dot net. I would like to try the sample..
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..

mimyanun
Newbie Poster
1 post since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

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!

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

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

Qbit75
Newbie Poster
9 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

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 ()

Please BE MORE specific.

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
Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

Paladine,

i'm also a relative newbie to asp.net, and i just wanted to thank you very much for your help! my login page worked perfectly thanks to your instructions.
heckman

heckman
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

hello
will is it possible to not give a response.redirect command to go other page
earlye

Qbit75
Newbie Poster
9 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

I am sorry but I do not understand what you are asking.


Ok? You don't want the user to go to next page on successful login? What is suppose to happen after login is completed? How would the user know where to go? If you mean another page other than default.aspx, I have to ask....have you reviewed the posts in this tutorial that speak of doing exactly that?


PLEASE be clear, specific and provide background information that may help me to help you get your questions answered

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

I think what he asked was:
Instead of
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) ' ||||| default.aspx Page! ,
can he use, Reponse.Redirect

The answer is Yes. Response.Redirect will do the work.

Kendel
Newbie Poster
12 posts since Feb 2005
Reputation Points: 10
Solved Threads: 1
 

Umm... ok. Thanks for answering that.

Yes!

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

yaa i want to do this but i want to redirect the user adminhome or userhom.aspx in your code it is possible that i define the particular page where a user go ?
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
at there how i define to go in next page just as userhome.aspx?

Qbit75
Newbie Poster
9 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Well you can do this one of two ways. Use Response.Redirect("userhome.aspx") or you could add the userhome.aspx as a possible default page under IIS settings for the application directory that will contain your ASP.Net Application.

yaa i want to do this but i want to redirect the user adminhome or userhom.aspx in your code it is possible that i define the particular page where a user go ? FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) at there how i define to go in next page just as userhome.aspx?
Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

hi but i dont knew how to set default property so if u have aby link then its good to me to understand it plz sand me that or describe it clearly ?

Qbit75
Newbie Poster
9 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Ok no worries

Start Menu --> Control Panel --> Administrative Tools --> Internet Information Services.

Drill down in the cascading menu to the folder name holding your ASP.NET Application. Right click on that folder, select properties, then go to the documents tab

[img]http://www3.telus.net/public/tmlohnes/Image1.jpg[/img]
Click add and then type in the name and extension of the new default page you want to use instead of the listed ones.

Voila!

Paladine
Master Poster
Team Colleague
824 posts since Feb 2003
Reputation Points: 211
Solved Threads: 27
 

Excuse me I am a novice in asp.net and i prove to create a new alogin application wirh this code, but my page don't make any check on the table when I make the submit return all the time at the login page. i prove to enter correct data and wrong data can yiou help me please??? :sad: :sad:

lorf14plus
Newbie Poster
20 posts since May 2005
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You