Its urgent(help me)

Posted by Rajivksharma under C# on 10/31/2008 | Views : 1422 | Status : [Member] | Replies : 3
In (C# Dot Net)windows Application I have one grid. In this grid one field is there ie. From date. I dont want dublicacy of this field.
If user enter dublicate record in this field then It must show some message. Plz give some example




Responses

Posted by: Jayakumars on: 9/30/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

first retrieve the data from db after check match or not from your controls.

Mark as Answer if its helpful to you

Rajivksharma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vivekjj on: 10/1/2012 [Member] Starter | Points: 25

Up
0
Down
sqlconnection con = new sqlconnection("your connectionstring");
sqlcommand cmd=new sqlcommand( "select * from + your table name + Where From date= + txtdate.text + "',con)
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
lblres="From date already exist";
}
cmd.Dispose();

Rajivksharma, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Majith on: 11/2/2008 [Member] Starter

Up
0
Down
Hi Rajiv,

1. First find the date text box in the grid like,

TextBox txtdt = (TextBox)Grid1.Rows[0].FindControl("txtDate");

2. Then get the datas to dataset ,GetDataset() is a method which holds the connections,commands etc.

DataSet ds = GetDataset();

for (int g = 0; g < ds.Tables[0].Rows.Count; g++)
{
if (txtdt.Text.ToString() == ds.Tables[0].Rows[g]["Date"].ToString())
{
lblres.Visible = true;
lblres.Text = "City Code Already Exist";
return;
}
}
3. Compare the values dataset field.



Rajivksharma, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response