Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
AnswerRe: Overriding the Label.CanSelect property Pin
Dave Kreskowiak30-Nov-05 5:56
mveDave Kreskowiak30-Nov-05 5:56 
GeneralRe: Overriding the Label.CanSelect property Pin
AnneThorne30-Nov-05 6:02
AnneThorne30-Nov-05 6:02 
GeneralRe: Overriding the Label.CanSelect property Pin
Dave Kreskowiak30-Nov-05 11:00
mveDave Kreskowiak30-Nov-05 11:00 
GeneralRe: Overriding the Label.CanSelect property Pin
AnneThorne30-Nov-05 11:07
AnneThorne30-Nov-05 11:07 
Questioncalling win32 dll in C# Pin
Manu_8129-Nov-05 11:51
Manu_8129-Nov-05 11:51 
AnswerRe: calling win32 dll in C# Pin
Mark DeVol29-Nov-05 12:46
Mark DeVol29-Nov-05 12:46 
GeneralRe: calling win32 dll in C# Pin
mikanu29-Nov-05 20:06
mikanu29-Nov-05 20:06 
QuestionQLMySQL Concurrency Violation Pin
Elvis_Pretzelator29-Nov-05 11:50
Elvis_Pretzelator29-Nov-05 11:50 
I've been trying to write to a MySQL db with no luck. Selecting the data and filling the dataSet is no problem. But everytime I try to update, delete or insert I get a concurrency violation. Am I just not mapping the columns correctly?

Database: address
Table: contacts

id int(11) not null auto_increment primary key
fname varchar(20)
lname varchar(20)
phone varchar(15)


Here's the code:

/*
* Created by SharpDevelop.
*
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Data.Odbc;
using System.Data.Common;

namespace mysql
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button btnLoad;
//
//
private OdbcConnection cnn=new OdbcConnection(@"DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=address;USER=root;PASSWORD=system;OPTION=3");
private OdbcDataAdapter da=new OdbcDataAdapter();
private DataSet ds=new DataSet();
private OdbcCommand selectCmd=new OdbcCommand();
private OdbcCommand insertCmd=new OdbcCommand();
private OdbcCommand updateCmd=new OdbcCommand();
private OdbcCommand deleteCmd=new OdbcCommand();
//
//

void MainFormLoad(object sender, System.EventArgs e)
{
this.da.SelectCommand=this.selectCmd;
this.da.InsertCommand=this.insertCmd;
this.da.UpdateCommand=this.updateCmd;
this.da.DeleteCommand=this.deleteCmd;
//
//table mappings
//
this.da.TableMappings.AddRange(new DataTableMapping[]
{
new DataTableMapping("Table","contacts", new DataColumnMapping[]
{
new DataColumnMapping("id","id"),
new DataColumnMapping("fname","fname"),
new DataColumnMapping("lname","lname"),
new DataColumnMapping("phone","phone")
})
});
//
//select command
//
this.selectCmd.CommandText="select id,fname,lname,phone from contacts";
this.selectCmd.Connection=this.cnn;
//
//delete command
//
this.deleteCmd.CommandText="delete from contacts where (id=@id) and
(fname=@fname) and (lname=@lname) and (phone=@phone)";
this.deleteCmd.Connection=this.cnn;
this.deleteCmd.Parameters.Add("@id",OdbcType.Int,4,"id");
this.deleteCmd.Parameters.Add("@fname",OdbcType.VarChar,20,"fname");
this.deleteCmd.Parameters.Add("@lname",OdbcType.VarChar,20,"lname");
this.deleteCmd.Parameters.Add("@phone",OdbcType.VarChar,15,"phone");
//
//insert command
//

this.insertCmd.CommandText="insert into contacts(fname,lname,phone)
values(@fname,@lname,@phone)";
this.insertCmd.Parameters.Add("@id",OdbcType.Int,4,"id");
this.insertCmd.Parameters.Add("@fname",OdbcType.VarChar,20,"fname");
this.insertCmd.Parameters.Add("@lname",OdbcType.VarChar,20,"lname");
this.insertCmd.Parameters.Add("@phone",OdbcType.VarChar,15,"phone");
this.insertCmd.Parameters["@id"].SourceVersion=DataRowVersion.Original;



}

void BtnLoadClick(object sender, System.EventArgs e)
{
this.cnn.Open();
this.da.SelectCommand=this.selectCmd;
this.da.Fill(ds);
this.cnn.Close();
//
this.dataGrid1.DataSource=ds;
this.dataGrid1.DataMember="contacts";
}

}
}



QuestionHow can i do a mouseover event for an asp object? Pin
Anthony Mushrow29-Nov-05 11:41
professionalAnthony Mushrow29-Nov-05 11:41 
AnswerRe: How can i do a mouseover event for an asp object? Pin
Dave Kreskowiak30-Nov-05 5:43
mveDave Kreskowiak30-Nov-05 5:43 
Questiondisposal of a homemade object Pin
melanieab29-Nov-05 10:35
melanieab29-Nov-05 10:35 
AnswerRe: disposal of a homemade object Pin
Dan Neely29-Nov-05 10:38
Dan Neely29-Nov-05 10:38 
GeneralRe: disposal of a homemade object Pin
melanieab29-Nov-05 11:14
melanieab29-Nov-05 11:14 
GeneralRe: disposal of a homemade object Pin
Dan Neely30-Nov-05 2:05
Dan Neely30-Nov-05 2:05 
Questionnetwork problem please help!!! Pin
snouto29-Nov-05 10:14
snouto29-Nov-05 10:14 
AnswerRe: network problem please help!!! Pin
mcljava29-Nov-05 12:33
mcljava29-Nov-05 12:33 
GeneralRe: network problem please help!!! Pin
snouto29-Nov-05 23:06
snouto29-Nov-05 23:06 
QuestionBack Button ASP.NET Pin
TheMajorRager29-Nov-05 10:02
TheMajorRager29-Nov-05 10:02 
QuestionCrystal Report setup problem Pin
sasan5629-Nov-05 9:56
sasan5629-Nov-05 9:56 
QuestionCreating a window form Pin
Yevgeny Efter29-Nov-05 8:45
Yevgeny Efter29-Nov-05 8:45 
AnswerRe: Creating a window form Pin
enjoycrack29-Nov-05 9:08
enjoycrack29-Nov-05 9:08 
GeneralRe: Creating a window form Pin
Yevgeny Efter29-Nov-05 9:25
Yevgeny Efter29-Nov-05 9:25 
GeneralRe: Creating a window form Pin
enjoycrack29-Nov-05 10:20
enjoycrack29-Nov-05 10:20 
QuestionFailed to compare Time portion of DateTime when read ACCESS database Pin
Roman Muntyanu29-Nov-05 7:58
Roman Muntyanu29-Nov-05 7:58 
AnswerRe: Failed to compare Time portion of DateTime when read ACCESS database Pin
Rob Philpott29-Nov-05 8:41
Rob Philpott29-Nov-05 8:41 

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.