Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
QuestionShowing xml string in web browser control Pin
sumit703412-Nov-08 21:18
sumit703412-Nov-08 21:18 
Questionhow to convert html page into image format Pin
hiren dave12-Nov-08 21:16
hiren dave12-Nov-08 21:16 
Questionproblem regarding publishing Pin
Seraph_summer12-Nov-08 20:24
Seraph_summer12-Nov-08 20:24 
AnswerRe: problem regarding publishing Pin
Vimalsoft(Pty) Ltd12-Nov-08 21:01
professionalVimalsoft(Pty) Ltd12-Nov-08 21:01 
GeneralRe: problem regarding publishing Pin
Seraph_summer12-Nov-08 21:55
Seraph_summer12-Nov-08 21:55 
GeneralRe: problem regarding publishing Pin
Vimalsoft(Pty) Ltd12-Nov-08 22:12
professionalVimalsoft(Pty) Ltd12-Nov-08 22:12 
GeneralRe: problem regarding publishing Pin
jas0n2313-Nov-08 22:00
jas0n2313-Nov-08 22:00 
QuestionConcurrency violation: the UpdateCommand affected 0 of the expected 1 records. Pin
Member 395385612-Nov-08 20:23
Member 395385612-Nov-08 20:23 
Hi there,

When I use the following code below I get and error called , "concurrency violation" and the database is not updated.

I am able to connect and retrieve data. but I cannot update the data from the datatable of dataset.

I am new to datagridview and datasets.

I am using Mysql 5.0 and Mysql connector .NET 5.1.2

I read many articles on updating the dataset and almost tried everything , but It does not work, I can update to Mysql database using update commands. But I want to use Dataset or dataadapter update to make it more simpler.


public partial class Form1 : Form
{

DataSet ds = new DataSet();
MySqlDataAdapter da;
DataTable dt = new DataTable();
string tabname;

public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
CreateMySqlCommand();
}


// Connecting to db and filling the datagridview with data.

public void CreateMySqlCommand()
{
MySqlConnection myConnection = new MySqlConnection("Persist Security
Info=False;userid=root;password=XXXX;database=test;server=terrain");
myConnection.Open();

MySqlTransaction myTrans = myConnection.BeginTransaction();
string mySelectQuery = "SELECT * FROM patient_master";
MySqlCommand myCommand = new MySqlCommand(mySelectQuery,
myConnection,myTrans);
da = new MySqlDataAdapter(mySelectQuery ,myConnection) ;
MySqlCommandBuilder cmdBldr = new MySqlCommandBuilder(da);
da.Fill(ds);


dt = ds.Tables[0];
DataRow row;
row = dt.Rows[0];
int lirow = dt.Rows.Count;
string mrno = row["MRNO"].ToString();
string patname = row["GIVEN_NAME"].ToString();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = ds.Tables[0].ToString();
tabname = dt.TableName;
int y = 0;
foreach (DataGridViewRow ro in dataGridView1.Rows)
{
if (y % 2 == 0)
ro.DefaultCellStyle.BackColor = Color.Red;
y++;
}

}

// code on the button to update the datadapter
private void button1_Click(object sender, EventArgs e)
{

da.Update(ds, tabname);

}


}
}
AnswerRe: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. Pin
Claudia P11-Feb-09 5:20
Claudia P11-Feb-09 5:20 
QuestionCan i use Windows Vista cursor "aero_busy.ani" in my windows application ? [modified] Pin
Krishnraj12-Nov-08 19:45
Krishnraj12-Nov-08 19:45 
QuestionSetting default validation summary Pin
Ajit S12-Nov-08 19:35
Ajit S12-Nov-08 19:35 
AnswerRe: Setting default validation summary Pin
AhsanS12-Nov-08 20:34
AhsanS12-Nov-08 20:34 
QuestionPass DataSet from Project1 to Project2 Pin
Illegal Operation12-Nov-08 16:36
Illegal Operation12-Nov-08 16:36 
AnswerRe: Pass DataSet from Project1 to Project2 Pin
N a v a n e e t h12-Nov-08 16:42
N a v a n e e t h12-Nov-08 16:42 
AnswerRe: Pass DataSet from Project1 to Project2 Pin
Vimalsoft(Pty) Ltd12-Nov-08 23:01
professionalVimalsoft(Pty) Ltd12-Nov-08 23:01 
GeneralRe: Pass DataSet from Project1 to Project2 Pin
Illegal Operation13-Nov-08 12:21
Illegal Operation13-Nov-08 12:21 
GeneralRe: Pass DataSet from Project1 to Project2 Pin
Vimalsoft(Pty) Ltd13-Nov-08 19:33
professionalVimalsoft(Pty) Ltd13-Nov-08 19:33 
QuestionLimitation of scroll of row header and column header Pin
kakel200812-Nov-08 15:08
kakel200812-Nov-08 15:08 
Questionhow to make exception serializable Pin
George_George12-Nov-08 14:22
George_George12-Nov-08 14:22 
AnswerRe: how to make exception serializable Pin
N a v a n e e t h12-Nov-08 17:03
N a v a n e e t h12-Nov-08 17:03 
GeneralRe: how to make exception serializable Pin
George_George12-Nov-08 17:52
George_George12-Nov-08 17:52 
GeneralRe: how to make exception serializable Pin
N a v a n e e t h12-Nov-08 19:38
N a v a n e e t h12-Nov-08 19:38 
GeneralRe: how to make exception serializable Pin
George_George12-Nov-08 21:25
George_George12-Nov-08 21:25 
GeneralRe: how to make exception serializable Pin
N a v a n e e t h13-Nov-08 15:09
N a v a n e e t h13-Nov-08 15:09 
GeneralRe: how to make exception serializable Pin
George_George16-Nov-08 2:15
George_George16-Nov-08 2:15 

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.