Click here to Skip to main content
15,885,804 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Translation:
Which code should I use write to validate one user to a database using visual studio?

Original Text:
¿Que codigo uso para poder validar un usuario en visual studio de una base de datos?
Posted
Updated 12-Aug-12 23:24pm
v6
Comments
Sergey Alexandrovich Kryukov 13-Aug-12 0:04am    
No matter what language you are using, this is not a question. And please understand -- this forum is based on English.
--SA
Sergey Alexandrovich Kryukov 13-Aug-12 0:04am    
Not a question. Please, use English only.
--SA
Sergey Alexandrovich Kryukov 13-Aug-12 1:05am    
OK, question marks added, but the question did not become more English.
Not clear what's meant by validation of a user. The code is not used, it should be written...
--SA
Joan M 13-Aug-12 5:26am    
Which database are you using? which kind of autenthification you are after? which is your goal? what have you tried till now? I'm from Spain and even English is not my mother tongue I try to keep it good (at least understandable) to other CPians. At least translate it... ;) oh, and try to make questions, not statements that don't mean anything. If you make a small effort you'll get lots of help.
Darkness_07 25-Aug-12 13:28pm    
check the userid and the password...if existing in the database

1 solution

Well, because I can not get 100% of what your talking about. I will answer all of the three things you might be talking about.
First off I am going to assume you are using MSSQL with visual studio, or MSSQL Express that most of the Visual studios have built into it.

Authentication to connect to a database from a visual studio application be it VB or C+ is outlined in the web.config page with a simple connection string, like so:

HTML
<add connectionstring="Server=SQLServer;Database=DatabaseName;UserID=DatabaseUser;Password=DatabasePassword" name="ConnectionStringName" providername="System.Data.SqlClient" />


Now once you have done this you can start referring to the connection string in either code or the front end wizards (The wizard select your connection string name from the drop down list in "Data sources"

As for in code (I will assume you are using vb.net) you can call it like so

VB
Dim cnn As New Odbc.OdbcConnection
cnn.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionStringName").ConnectionString


If of course you are speaking about enabled .Net authentication to your application (Which is also controlled via the web.config) I would suggest reading up a little on the authentication levels of ASP apps, the visual studio wizard can create these authentication databases for you which you will learn from investigating the .Net user auth.

Zac
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900