Reputation: 17
I have a simple html 5 login page, I need to open a sql connection and have a condition to match the entered details and match or not.
code i have right now is this
Email Address: <input id="Text1" type="text" />
Password: <input id="Password1" type="password" />
<input id="Submit1" type="submit" value="Submit" onclick="loginFunction()"/>
<input id="Reset1" type="reset" value="Cancel" />
I have created onclick
function. Please help me to open a sql connection and verify the login details
Upvotes: 1
Views: 2543
Reputation: 1365
If you are using sql server ms as databse and c# as the server side coding,which i assume you must be using . In the Page Load Or On the Button Click Event Establish a connection string as below.
string connectionString="Data Source=servername;InitialCatalog=DataBaseName;UserID=sa; Password=YourPassword;"
Now create an Sql Connection object and open the connection
SqlConnection sqlConnection=new SqlConnection(connectionString);
sqlConnection.open();
Now the database connection is set.If you want to fire any queries now use Sql Command Class.The Parameters of the sqlcommand object are the querystring and connection object.
string insertStatement="INSERT INTO TableName(column1,column2) VALUES Txtb1+","+Txtb2";
SqlCommand sqlCommand=new SqlCommand(insertStatement,sqlConnection);
Upvotes: -1
Reputation: 1194
You need a server side to retrieve data.
You have a bunch of databases that you can use.
Going for a mysql database would be a nice approach as it is 100% open source, very simple and it offers stability, if you choose it advice you to choose php for server side, it is old and not very power full but is good for simple pages and for beginners.
If you prefer a NoSQL database you can chose mongoDb for example and (although i have no experience with this) I think that you can link to the database with json
Upvotes: 2