Click here to Skip to main content
16,004,833 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questioncalendar popup Pin
ankitjain111031-Aug-09 1:59
ankitjain111031-Aug-09 1:59 
AnswerRe: calendar popup Pin
sashidhar31-Aug-09 2:22
sashidhar31-Aug-09 2:22 
GeneralRe: calendar popup Pin
ankitjain111031-Aug-09 2:45
ankitjain111031-Aug-09 2:45 
AnswerRe: calendar popup Pin
Abhijit Jana31-Aug-09 2:54
professionalAbhijit Jana31-Aug-09 2:54 
GeneralRe: calendar popup Pin
ankitjain111031-Aug-09 3:00
ankitjain111031-Aug-09 3:00 
AnswerRe: calendar popup Pin
Abhijit Jana31-Aug-09 3:14
professionalAbhijit Jana31-Aug-09 3:14 
QuestionGenerate xml file from sql server in asp.net Pin
.NET- India 31-Aug-09 1:56
.NET- India 31-Aug-09 1:56 
AnswerRe: Generate xml file from sql server in asp.net Pin
compninja2531-Aug-09 4:31
compninja2531-Aug-09 4:31 
GeneralRe: Generate xml file from sql server in asp.net Pin
compninja2531-Aug-09 6:16
compninja2531-Aug-09 6:16 
AnswerRe: Generate xml file from sql server in asp.net Pin
www.Developerof.NET31-Aug-09 7:28
www.Developerof.NET31-Aug-09 7:28 
QuestionDiv overlapping Pin
meghamaharshi31-Aug-09 1:38
meghamaharshi31-Aug-09 1:38 
AnswerRe: Div overlapping Pin
sashidhar31-Aug-09 1:52
sashidhar31-Aug-09 1:52 
QuestionOpacity mask in IE8 Pin
vikash_singh31-Aug-09 1:38
vikash_singh31-Aug-09 1:38 
QuestionCould you help me in ASP.Net. Pin
abglorie31-Aug-09 1:19
abglorie31-Aug-09 1:19 
AnswerRe: Could you help me in ASP.Net. [modified] Pin
sashidhar31-Aug-09 1:40
sashidhar31-Aug-09 1:40 
AnswerRe: Could you help me in ASP.Net. Pin
Abhijit Jana31-Aug-09 3:10
professionalAbhijit Jana31-Aug-09 3:10 
Questionhow to open filled page which was not saved due to system has shutdown Pin
itsmitm31-Aug-09 1:08
itsmitm31-Aug-09 1:08 
Questionimage in ASP.Net Pin
Amit Patel198531-Aug-09 0:49
Amit Patel198531-Aug-09 0:49 
AnswerRe: image in ASP.Net Pin
myinstincts31-Aug-09 1:30
myinstincts31-Aug-09 1:30 
AnswerRe: image in ASP.Net Pin
mylogics31-Aug-09 1:30
professionalmylogics31-Aug-09 1:30 
GeneralRe: image in ASP.Net Pin
Amit Patel198531-Aug-09 2:17
Amit Patel198531-Aug-09 2:17 
GeneralRe: image in ASP.Net Pin
sashidhar31-Aug-09 2:25
sashidhar31-Aug-09 2:25 
GeneralRe: image in ASP.Net Pin
Abhijit Jana31-Aug-09 2:49
professionalAbhijit Jana31-Aug-09 2:49 
GeneralRe: image in ASP.Net Pin
Amit Patel198531-Aug-09 3:38
Amit Patel198531-Aug-09 3:38 
Questionaccess Pin
mylogics31-Aug-09 0:46
professionalmylogics31-Aug-09 0:46 
hiii
i have a Product.db table in which i have columns:
PID:Autonumber
ProductID:indexed(yes (no duplicate))
Productname:
ProductDescription:
ProductPrice:
VendorID:
m using following code to insert data n update data on button click in my table:
protected void Button4_Click(object sender, EventArgs e)
    {
        string str1 = "Select MAX(PID) From Product";
        OleDbCommand cmd = new OleDbCommand(str1, conn);
        OleDbDataReader dr = null;
        conn.Open();
        string max = cmd.ExecuteScalar().ToString();
        if (max != "")
        {
            max = "PID" + max;

        }
        else
        {
            max = "PID" + 1;
        }
        conn.Close();   
        string str = "Insert Into Product(ProductID,ProductName,ProductDescription,ProductPrice)Values('"+max+"','" + txtprdtname.Text + "','" + txtprdtdescrp.Text + "','" + txtprdtprice.Text + "')";
         cmd = new OleDbCommand(str, conn);
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        str = "Select * From Product";
        cmd = new OleDbCommand(str, conn);
        OleDbDataReader dr1 = null;
        conn.Open();
        dr1 = cmd.ExecuteReader();
        DropDownList2.DataSource = dr1;
        DropDownList2.DataTextField = "ProductID";
        DropDownList2.DataValueField = "ProductID";
        DropDownList2.DataBind();
        conn.Close();

        string str3 = "Select Max(PID) From Product";
        cmd = new OleDbCommand(str3, conn);
        conn.Open();
        string max1 = cmd.ExecuteScalar().ToString();
        string max2 = "PID" + max1;
        conn.Close();
        string str2 = "Update Product Set ProductID='" + max2 + "' Where(PID=" + max1 + ")";
        cmd = new OleDbCommand(str2, conn);
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();

    }

but when i execute it i get following error:

The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

Plz guide me where m i wrong....

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.