Click here to Skip to main content
15,917,859 members
Home / Discussions / Database
   

Database

 
AnswerRe: Error with Jet 4.0 Pin
albCode15-Dec-05 5:45
albCode15-Dec-05 5:45 
GeneralRe: Error with Jet 4.0 Pin
vilmer15-Dec-05 22:05
vilmer15-Dec-05 22:05 
GeneralRe: Error with Jet 4.0 Pin
Rob Graham16-Dec-05 13:26
Rob Graham16-Dec-05 13:26 
GeneralRe: Error with Jet 4.0 Pin
vilmer17-Dec-05 1:19
vilmer17-Dec-05 1:19 
QuestionDatabase migration tool Pin
AnonymousTwo15-Dec-05 4:40
AnonymousTwo15-Dec-05 4:40 
AnswerRe: Database migration tool Pin
-Dr_X-19-Dec-05 11:58
-Dr_X-19-Dec-05 11:58 
QuestionColumnOrder Pin
silverear15-Dec-05 2:36
silverear15-Dec-05 2:36 
AnswerRe: ColumnOrder Pin
toxcct15-Dec-05 3:07
toxcct15-Dec-05 3:07 
QuestionJOIN two objects from different sources Pin
serious-sam14-Dec-05 12:48
serious-sam14-Dec-05 12:48 
AnswerRe: JOIN two objects from different sources Pin
-Dr_X-19-Dec-05 12:00
-Dr_X-19-Dec-05 12:00 
QuestionMigrating from SQL Server 2000 to 2005 Pin
PrashantJ14-Dec-05 10:15
PrashantJ14-Dec-05 10:15 
AnswerRe: Migrating from SQL Server 2000 to 2005 Pin
albCode14-Dec-05 21:18
albCode14-Dec-05 21:18 
GeneralRe: Migrating from SQL Server 2000 to 2005 Pin
PrashantJ15-Dec-05 6:31
PrashantJ15-Dec-05 6:31 
QuestionDelete duplicate records Pin
munklefish14-Dec-05 6:34
munklefish14-Dec-05 6:34 
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 

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.