|

|
protected void btnlogin_Click(object sender, EventArgs e)
{
//sql connection
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "Your connection";
cnn.Open();
SqlCommand cmd = new SqlCommand("select mobileno, password from register where mobileno='"+txtmoblie.Text +"'and password='"+txtpassword.Text+"'",cnn);
cmd.Connection = cnn;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Redirect("http://www.google.com");
}
else
{
Response.Write(@"<script language="'javascript'">alert('Invalid Username and Password')</script>");
}
cnn.Close();
}
Happy coding
modified 12-Dec-11 23:50pm.
|
|
|
|

|
Hi
This code is basically for storing the data from datagridview to sql server
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MIC
public Form1()
{
InitializeComponent();
}
public SqlConnection getsqlcon()
{
string connstring = "Server Name";
SqlConnection con = new SqlConnection(connstring);
return con;
}
public bool getcomm(string connstring1)
{
try
{
SqlConnection sqlcon = this.getsqlcon();
SqlCommand sqlcomm = new SqlCommand(connstring1,sqlcon);
sqlcon.Open();
sqlcomm.ExecuteNonQuery();
sqlcomm.Dispose();
sqlcon.Close();
sqlcon.Dispose();
return true;
}
catch(Exception ex)
{
return false;
}
private void btnsubmit_Click(object sender, EventArgs e)
{
try
{
string col1 = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string col2 = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string col3 = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string col4 = dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string insert_sql = "insert into clientwiseproductwise(col1,col2,col3,col4)values('" + col1 + "','" + col2 + "','" + col3 + "','" + col4 + "')",con;
if (this.getcomm(insert_sql))
{
MessageBox.Show("Insert Success");
}
else
{
MessageBox.Show("Insert Failed");
}
}
catch
{
}
Happy coding
|
|
|
|