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 Leptonlibrary;
using System.Collections;
namespace AddressExtractor
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
LeptonDataLayer.MySqlConnectionString = "server=192.168.1.224; user id=root; password=lepton; database=leptondata; pooling=false;default command timeout=3600;";
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (txtUserName.Text == "")
{
MessageBox.Show("Please Enter UserName");
txtUserName.Focus();
return;
}
if (txtPassword.Text == "")
{
MessageBox.Show("Please Enter Password");
txtPassword.Focus();
return;
}
if (ddlCityName.Text != "")
{
this.Hide();
Form1 frmmain = new Form1();
frmmain.UserName = txtUserName.Text;
frmmain.CityName = ddlCityName.Text;
string cityname = frmmain.CityName;
string newcituname = string.Empty;
newcituname = cityname;
frmmain.NewCityName = newcituname;
string SqlQuery = "Update " + frmmain.CityName + " set assignedtouserid='" + frmmain.UserName + "', flag=1 where flag=0 and city like '%" + newcituname + "%' ORDER BY LOCALITY DESC limit 100 ";
LeptonDataLayer.ExecuteNoneQuery(1, SqlQuery);
SqlQuery = "Update userlogin set LoginDateTime=NOW() where UserName='" + frmmain.UserName + "'";
LeptonDataLayer.ExecuteNoneQuery(1, SqlQuery);
frmmain.ShowDialog();
}
else
{ MessageBox.Show("Please Select CityName"); }
}
private void txtPassword_Leave(object sender, EventArgs e)
{
string SqlQuery = "Select CityName from userlogin where UserName='" + txtUserName.Text + "' and Password='" + txtPassword.Text + "'";
DataTable dtddl = LeptonDataLayer.ExecuteDataTable(1, SqlQuery);
if (dtddl.Rows.Count > 0)
{
for (int i = 0; i < dtddl.Rows.Count; i++)
ddlCityName.Items.Add(dtddl.Rows[i]["CityName"].ToString());
}
else
MessageBox.Show("Incorrect UserName And Password");
}
}
}
when i m running the following code i have following error
"Object reference not set to an instance of an object."
in my mysql leptondata database i have a table userlogin which have following field UserName,Password and CityName.
what is problem in above code pls tell me