Click here to Skip to main content
15,889,216 members
Home / Discussions / Database
   

Database

 
AnswerRe: Delete duplicate records Pin
enjoycrack14-Dec-05 7:13
enjoycrack14-Dec-05 7:13 
GeneralRe: Delete duplicate records Pin
munklefish14-Dec-05 11:46
munklefish14-Dec-05 11:46 
GeneralRe: Delete duplicate records Pin
enjoycrack14-Dec-05 11:49
enjoycrack14-Dec-05 11:49 
GeneralRe: Delete duplicate records Pin
munklefish14-Dec-05 11:54
munklefish14-Dec-05 11:54 
GeneralRe: Delete duplicate records Pin
enjoycrack14-Dec-05 14:53
enjoycrack14-Dec-05 14:53 
AnswerRe: Delete duplicate records Pin
albCode15-Dec-05 6:00
albCode15-Dec-05 6:00 
GeneralRe: Delete duplicate records Pin
munklefish15-Dec-05 6:15
munklefish15-Dec-05 6:15 
QuestionHelp please ... i don't know what is wrong!! Pin
UltraMAX2K514-Dec-05 5:05
UltraMAX2K514-Dec-05 5:05 
Hello, i'm novice with Visual C# and SQL Server, so can someone help me please ... i want search for a record in the database, and if it is found then i move the CurrencyManager position to its position but i got this error:
ConstraintException was unhandled:
Column 'cd_id' is constrained to be unique.  Value '9463216602' is already present.


in my database this field [cd_id] in both tables aren't the primary key, are just simple fields ... what's i'm doing wrong, can someone help me please, i'm using this code:

the general variables:
<br />
SqlConnection myConnection;<br />
SqlDataAdapter daCD, daTemas;<br />
DataSet myDataSet = new DataSet("MusicaTeca");<br />
DataViewManager myDVM;<br />
CurrencyManager cm;<br />


in the form_load:
<br />
private void frmProduto_Load(object sender, EventArgs e)<br />
{<br />
   myConnection = new SqlConnection(<br />
      "Server=(local)\\SQLEXPRESS;DataBase=musicateca;" +<br />
      "integrated Security=SSPI");<br />
<br />
   daCD = new SqlDataAdapter("SELECT * FROM tbl_cds", myConnection);<br />
   daCD.TableMappings.Add("Table", "tbl_scds");<br />
   daCD.Fill(myDataSet, "tbl_cds");<br />
<br />
   daTemas = new SqlDataAdapter("SELECT * FROM tbl_temas", myConnection);<br />
   daTemas.TableMappings.Add("Table", "tbl_temas");<br />
   daTemas.Fill(myDataSet, "tbl_temas");<br />
<br />
   myDVM = myDataSet.DefaultViewManager;<br />
<br />
   DataRelation relCD_Tema;<br />
   DataColumn parentCol, childCol;<br />
   parentCol = myDataSet.Tables["tbl_cds"].Columns["cd_id"];<br />
   childCol = myDataSet.Tables["tbl_temas"].Columns["cd_id"];<br />
   relCD_Tema = new DataRelation("RelCD_Temas", parentCol, childCol);<br />
   myDataSet.Relations.Add(relCD_Tema);<br />
<br />
   txtAlbum.DataBindings.Add("Text", myDVM, "tbl_cds.album");<br />
   txtAno.DataBindings.Add("Text", myDVM, "tbl_cds.ano");<br />
   txtArtista.DataBindings.Add("Text", myDVM, "tbl_cds.artista");<br />
   txtEditora.DataBindings.Add("Text", myDVM, "tbl_cds.editora");<br />
   txtGenero.DataBindings.Add("Text", myDVM, "tbl_cds.genero");<br />
   txtID.DataBindings.Add("Text", myDVM, "tbl_cds.cd_id");<br />
<br />
   dbGrid.DataSource = myDVM;<br />
   dbGrid.DataMember = "tbl_cds.RelCD_Temas";<br />
   dbGrid.Columns["reg_id"].Visible = false;<br />
   dbGrid.Columns["cd_id"].Visible = false;<br />
<br />
   cm = (CurrencyManager)this.BindingContext[myDVM, "tbl_cds"];<br />
}<br />


and the search button_click:
<br />
private void btnLocalizar_Click(object sender, EventArgs e)<br />
{<br />
    int intRow;<br />
<br />
    myDVM.DataViewSettings["tbl_cds"].Sort = "cd_id";<br />
    intRow = myDataSet.Tables["tbl_cds"].DefaultView.Find(txtID.Text);<br />
<br />
    if (intRow > 0)<br />
    {<br />
        cm.Position = intRow;   // The Error is in this line.<br />
        cm.Refresh();<br />
    }<br />
    else<br />
    {<br />
         MessageBox.Show("Registo não localizado!");<br />
    }<br />
}<br />


can someone help me please ... and forgive me my bad english.

Thanks
UltraMAX
AnswerRe: Help please ... i don't know what is wrong!! Pin
Rob Graham14-Dec-05 5:22
Rob Graham14-Dec-05 5:22 
AnswerRe: Help please ... i don't know what is wrong!! Pin
agauga14-Dec-05 5:24
agauga14-Dec-05 5:24 
AnswerRe: Help please ... i don't know what is wrong!! Pin
UltraMAX2K514-Dec-05 8:09
UltraMAX2K514-Dec-05 8:09 
QuestionSQL-SERVER 2000 storing documents Pin
agauga14-Dec-05 5:02
agauga14-Dec-05 5:02 
AnswerRe: SQL-SERVER 2000 storing documents Pin
Colin Angus Mackay14-Dec-05 6:43
Colin Angus Mackay14-Dec-05 6:43 
GeneralRe: SQL-SERVER 2000 storing documents Pin
agauga14-Dec-05 19:08
agauga14-Dec-05 19:08 
QuestionSimple SQL delete statement Pin
munklefish14-Dec-05 2:30
munklefish14-Dec-05 2:30 
AnswerRe: Simple SQL delete statement Pin
albCode14-Dec-05 4:19
albCode14-Dec-05 4:19 
GeneralRe: Simple SQL delete statement Pin
munklefish14-Dec-05 4:20
munklefish14-Dec-05 4:20 
GeneralRe: Simple SQL delete statement Pin
albCode14-Dec-05 4:25
albCode14-Dec-05 4:25 
QuestionSQL Express and Learning Center Video Pin
Brigg Thorp13-Dec-05 3:59
Brigg Thorp13-Dec-05 3:59 
QuestionSQLEXPRESS Pin
Illegal Operation13-Dec-05 2:47
Illegal Operation13-Dec-05 2:47 
AnswerRe: SQLEXPRESS Pin
enjoycrack13-Dec-05 7:37
enjoycrack13-Dec-05 7:37 
QuestionSQL Pin
dev_rfid13-Dec-05 1:09
dev_rfid13-Dec-05 1:09 
AnswerRe: SQL Pin
Ritesh123413-Dec-05 2:19
Ritesh123413-Dec-05 2:19 
AnswerRe: SQL Pin
toxcct13-Dec-05 23:27
toxcct13-Dec-05 23:27 
AnswerRe: SQL Pin
miah alom14-Dec-05 4:24
miah alom14-Dec-05 4:24 

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.