Click here to Skip to main content
16,012,468 members
Home / Discussions / Database
   

Database

 
GeneralRe: Stored Procedure Question Pin
Brent Lamborn18-May-07 3:17
Brent Lamborn18-May-07 3:17 
QuestionAdding a new record to a DataSet Pin
Quecumber25617-May-07 10:21
Quecumber25617-May-07 10:21 
AnswerRe: Missing Code Pin
Quecumber25617-May-07 10:24
Quecumber25617-May-07 10:24 
GeneralRe: Missing Code Pin
gauthee17-May-07 20:11
gauthee17-May-07 20:11 
GeneralRe: Missing Code Pin
Quecumber25618-May-07 3:05
Quecumber25618-May-07 3:05 
QuestionHow to convert varchar to int on the view Pin
teddddddddddd17-May-07 9:35
teddddddddddd17-May-07 9:35 
AnswerRe: How to convert varchar to int on the view Pin
Hulicat17-May-07 14:31
Hulicat17-May-07 14:31 
Questionduplicate keys Pin
seemamltn17-May-07 9:23
seemamltn17-May-07 9:23 
Hi,

I have dropdownlist named ddlapplication in my web form. When I click any item it insert
that record in database with primary key and show in gridview.
If user try to add the same record next time by clicking same item from the dropdown list
which already exist in database it should show error message that this
record alredy exist or in other words before inserting it should check wheather the record is already in database or not.

How can I do that. Here is my code

string str1 = this.ddlApplication.DataTextField;
string str2 = this.ddlApplication.SelectedValue;
string str3 = this.ddlPermission.SelectedItem.Value;


String constr = System.Configuration.ConfigurationManager.ConnectionStrings["twcsanConnectionString"].ConnectionString;
SqlConnection objConn = new SqlConnection(constr);
SqlCommand objCmd = new SqlCommand("INSERT INTO tbUsersAppRights(AppId, AppRightId, UserId) " +
"VALUES (@str1,@str2,@str3)", objConn);
objCmd.Parameters.AddWithValue("@str1", int.Parse(this.ddlApplication.SelectedValue));
objCmd.Parameters.AddWithValue("@str2", int.Parse(this.ddlPermission.SelectedValue));
objCmd.Parameters.AddWithValue("@str3", int.Parse(this.lblUserid11.Text));

objConn.Open();
objCmd.ExecuteNonQuery();
objConn.Close();
this.gdAddUser.DataBind();


seema

AnswerRe: duplicate keys Pin
gauthee17-May-07 19:48
gauthee17-May-07 19:48 
QuestionCompound primary keys in access? Pin
Dan Neely17-May-07 4:20
Dan Neely17-May-07 4:20 
AnswerRe: Compound primary keys in access? Pin
andyharman17-May-07 5:06
professionalandyharman17-May-07 5:06 
Questiondelete query for deleting duplicate rows efficiently Pin
VaibhavTiparadi17-May-07 3:40
VaibhavTiparadi17-May-07 3:40 
AnswerRe: delete query for deleting duplicate rows efficiently Pin
andyharman17-May-07 5:13
professionalandyharman17-May-07 5:13 
AnswerRe: delete query for deleting duplicate rows efficiently Pin
Arun.Immanuel17-May-07 6:13
Arun.Immanuel17-May-07 6:13 
QuestionMax Rows in MS-Access 2000 Pin
.NET- India 17-May-07 1:48
.NET- India 17-May-07 1:48 
AnswerRe: Max Rows in MS-Access 2000 Pin
Dave Kreskowiak17-May-07 6:50
mveDave Kreskowiak17-May-07 6:50 
Questionhow to cast nvarchar in to date type in sql Pin
rkherath16-May-07 23:10
rkherath16-May-07 23:10 
AnswerRe: how to cast nvarchar in to date type in sql Pin
WoutL16-May-07 23:42
WoutL16-May-07 23:42 
GeneralRe: how to cast nvarchar in to date type in sql Pin
rkherath17-May-07 0:10
rkherath17-May-07 0:10 
GeneralRe: how to cast nvarchar in to date type in sql Pin
gauthee17-May-07 0:12
gauthee17-May-07 0:12 
GeneralRe: how to cast nvarchar in to date type in sql Pin
rkherath17-May-07 0:25
rkherath17-May-07 0:25 
GeneralRe: how to cast nvarchar in to date type in sql Pin
gauthee17-May-07 0:47
gauthee17-May-07 0:47 
GeneralRe: how to cast nvarchar in to date type in sql Pin
rkherath17-May-07 1:41
rkherath17-May-07 1:41 
GeneralRe: how to cast nvarchar in to date type in sql Pin
rkherath17-May-07 1:45
rkherath17-May-07 1:45 
GeneralRe: how to cast nvarchar in to date type in sql Pin
gauthee17-May-07 1:49
gauthee17-May-07 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.