Click here to Skip to main content
15,923,120 members
Home / Discussions / C#
   

C#

 
QuestionGlobal access Pin
B I Khan29-Nov-05 17:38
B I Khan29-Nov-05 17:38 
AnswerRe: Global access Pin
Christian Graus29-Nov-05 17:42
protectorChristian Graus29-Nov-05 17:42 
QuestionRegarding Page Navigation at server side. Pin
Murthy India29-Nov-05 17:25
Murthy India29-Nov-05 17:25 
AnswerRe: Regarding Page Navigation at server side. Pin
Ankit Aneja29-Nov-05 23:28
Ankit Aneja29-Nov-05 23:28 
GeneralRe: Regarding Page Navigation at server side. Pin
Murthy India2-Dec-05 0:44
Murthy India2-Dec-05 0:44 
GeneralRe: Regarding Page Navigation at server side. Pin
Ankit Aneja2-Dec-05 1:10
Ankit Aneja2-Dec-05 1:10 
GeneralRe: Regarding Page Navigation at server side. Pin
Murthy India2-Dec-05 18:14
Murthy India2-Dec-05 18:14 
GeneralRe: Regarding Page Navigation at server side. Pin
Ankit Aneja2-Dec-05 18:28
Ankit Aneja2-Dec-05 18:28 
QuestionPoor company - do we need an obfuscator? Pin
Libor Tinka29-Nov-05 13:09
Libor Tinka29-Nov-05 13:09 
AnswerRe: Poor company - do we need an obfuscator? Pin
Christian Graus29-Nov-05 13:54
protectorChristian Graus29-Nov-05 13:54 
GeneralRe: Poor company - do we need an obfuscator? Pin
Libor Tinka30-Nov-05 0:51
Libor Tinka30-Nov-05 0:51 
AnswerRe: Poor company - do we need an obfuscator? Pin
leppie29-Nov-05 22:25
leppie29-Nov-05 22:25 
AnswerRe: Poor company - do we need an obfuscator? Pin
Rob Philpott30-Nov-05 1:12
Rob Philpott30-Nov-05 1:12 
GeneralRe: Poor company - do we need an obfuscator? Pin
leppie30-Nov-05 3:33
leppie30-Nov-05 3:33 
QuestionTransaction Rollback timeout Pin
Mark DeVol29-Nov-05 12:51
Mark DeVol29-Nov-05 12:51 
AnswerRe: Transaction Rollback timeout Pin
rakesh_nits29-Nov-05 23:55
rakesh_nits29-Nov-05 23:55 
QuestionOverriding the Label.CanSelect property Pin
AnneThorne29-Nov-05 12:39
AnneThorne29-Nov-05 12:39 
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";
}

}
}



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.