*These
namespaces are must be required for SqlServer Connectivity in your web form:-
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
App.config File
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<appSettings>
<add key="ConnectionString" value="Data Source=PRADEEP-HP;Initial Catalog=Decofloore2;User
ID=User_006;Password=user006"/>
</appSettings>
</configuration>
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace DemoWindowApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnUsrId_Click(object sender, EventArgs e)
{
string StrCon = ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection SqlCon = new SqlConnection(StrCon);
string SqlQuery = "Select
Name,Address,MobileNo,EmailID,DOB from ShowOnePage where RegistrationId='" + textRegId.Text.Trim() + "'";
SqlCommand SqlComm = new SqlCommand(SqlQuery, SqlCon);
SqlCon.Open();
SqlDataReader dr;
dr = SqlComm.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{
textName.Text = dr["Name"].ToString();
textAddress.Text = dr["Address"].ToString();
textPhNo.Text = dr["MobileNo"].ToString();
textEmailId.Text = dr["EmailID"].ToString();
}
}
private void btnReset_Click(object sender, EventArgs e)
{
textEmailId.Text = "";
textName.Text = "";
textPhNo.Text = "";
textAddress.Text = "";
lblMsg.Text = "";
textRegId.Text = "";
}
private void btnNext_Click(object sender, EventArgs e)
{
Form2 obj2 = new Form2();
obj2.Show();
this.Hide();
}
}
}
0 comments
Post a Comment