Login And Registration Form With C#
Please how can i create login and registration form for many users with c#. Thanks.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yogesh SharmaPosted Feb 26, 2016, 4:22 AM
Krishna Rajput SinghPosted Feb 26, 2016, 4:39 AM
Amit Kumar SinghPosted Feb 26, 2016, 4:11 AM
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Registration
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
string str;
protected void btnadd_Click(object sender, EventArgs e)
{
ExecuteInsert(RegistrationText.Text, MakeText.Text, ModelText.Text, FuelTypeText.Text, CapacityText.Text, BhpText.Text, MileageText.Text);
Response.Write("Record was successfully added!");
clear();
}
private void ExecuteInsert(string RegistrationNumber, string Make, string Model, string FuelType, string Capacity, string Power, string Mileage)
{
SqlConnection con = new SqlConnection(connStr);
str = "INSERT INTO Vehicles (RegistrationNumber, Make, Model, FuelType, Capacity, Power, Mileage) VALUES (@RegistrationNumber, @Make, @Model, @FuelType, @Capacity, @Power, @Mileage)";
try
{
con.Open();
com = new SqlCommand(str, con);
SqlParameter[] param = new SqlParameter[7];
param[0] = new SqlParameter("@RegistrationNumber", SqlDbType.NVarChar, 10);
param[1] = new SqlParameter("@Make", SqlDbType.NVarChar, 30);
param[2] = new SqlParameter("@Model", SqlDbType.NVarChar, 30);
param[3] = new SqlParameter("@FuelType", SqlDbType.NVarChar, 10);
param[4] = new SqlParameter("@Capacity", SqlDbType.Int, 4);
param[5] = new SqlParameter("@Power", SqlDbType.Int, 4);
param[6] = new SqlParameter("@Mileage", SqlDbType.Int, 8);
param[0].Value = RegistrationNumber;
param[1].Value = Make;
param[2].Value = Model;
param[3].Value = FuelType;
param[4].Value = Capacity;
param[5].Value = Power;
param[6].Value = Mileage;
for (int i = 0; i < param.Length; i++)
{
com.Parameters.Add(param[i]);
}
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Insert Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
con.Close();
}
}
void clear()
{
RegistrationText.Text = "";
MakeText.Text = "";
ModelText.Text = "";
FuelTypeText.Text = "";
CapacityText.Text = "";
BhpText.Text = "";
MileageText.Text = "";
}
}
Shubham KumarPosted Feb 26, 2016, 4:09 AM