Click here to Skip to main content
15,886,110 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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....
AnswerRe: access Pin
Coding C#31-Aug-09 3:33
Coding C#31-Aug-09 3:33 
GeneralRe: access Pin
mylogics31-Aug-09 21:02
professionalmylogics31-Aug-09 21:02 
QuestionSecurity Exception in ASP.net Pin
Leezo8730-Aug-09 23:18
Leezo8730-Aug-09 23:18 
AnswerRe: Security Exception in ASP.net Pin
Aman Bhullar31-Aug-09 0:40
Aman Bhullar31-Aug-09 0:40 
QuestionRole & membership Pin
KhandelwalA30-Aug-09 23:02
KhandelwalA30-Aug-09 23:02 
AnswerRe: Role & membership Pin
sashidhar30-Aug-09 23:31
sashidhar30-Aug-09 23:31 
QuestionHow to read web.config file from a different site? Pin
pubududilena30-Aug-09 22:18
pubududilena30-Aug-09 22:18 
AnswerRe: How to read web.config file from a different site? Pin
Abhishek Sur30-Aug-09 22:58
professionalAbhishek Sur30-Aug-09 22:58 
GeneralRe: How to read web.config file from a different site? Pin
Gaurav Dudeja India31-Aug-09 0:03
Gaurav Dudeja India31-Aug-09 0:03 
GeneralRe: How to read web.config file from a different site? Pin
Abhishek Sur31-Aug-09 23:17
professionalAbhishek Sur31-Aug-09 23:17 
Questiondate problem [modified] Pin
venu65630-Aug-09 22:03
venu65630-Aug-09 22:03 
AnswerRe: date problem Pin
dan!sh 30-Aug-09 22:16
professional dan!sh 30-Aug-09 22:16 
GeneralRe: date problem Pin
venu65630-Aug-09 22:24
venu65630-Aug-09 22:24 
GeneralRe: date problem Pin
dan!sh 30-Aug-09 22:26
professional dan!sh 30-Aug-09 22:26 
GeneralRe: date problem Pin
venu65630-Aug-09 22:32
venu65630-Aug-09 22:32 
AnswerRe: date problem Pin
Abhishek Sur30-Aug-09 22:56
professionalAbhishek Sur30-Aug-09 22:56 
GeneralRe: date problem Pin
venu65630-Aug-09 23:07
venu65630-Aug-09 23:07 

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.