Databases :: Transaction In Mysql For Update For Each Row Of Gridview
Feb 2, 2011
i am having a transaction related problem regarding mysql.. need some advice how to proceed !!!
here is a gridview for my application and i am inserting or updating for each row.... like
[Code]....
well now what i want is if any of the row update or insert failes ... it should revert all the changes that was already made into the database ... even a single row update .. into that perticular table ... the code which i have called for payment.Update(PayDetails, 0) is :
[Code]....
can someone help me out how to proceed in this scenario ??? how do i undo each of the updates made into the table payment schedule details ...
I'm trying to delete a bunch of records in mysql. The record info to delete (userid, name) is stored in an arraylist. It seems to only delete the first record and gives an error ("Transaction has already been rolled back or is not pending.") afterwards. I have the transaction commit inside the loop which I think is the issue but not sure how to go further if I bring it outside of the loop. Here's the relevant bits of the code.
try { ArrayList alist = new ArrayList(); //alist gets populated with data like (12345,robot)(23456,car) here. MySqlConnection conn2 = new MySqlConnection(query_connection); conn2.Open(); MySqlCommand command2 = conn2.CreateCommand(); MySqlTransaction mytransaction; mytransaction = conn2.BeginTransaction(); command2.Transaction = mytransaction; for (int i = 0; i < alist.Count; i++) { string[] s = alist[i].ToString().Split(','); try { command2.CommandText = "DELETE from users_settings WHERE UserID=" + s[0].ToString(); command2.ExecuteNonQuery(); command2.CommandText = "DELETE from users WHERE ID=" + s[0].ToString(); command2.ExecuteNonQuery(); mytransaction.Commit(); } catch (Exception e){ mytransaction.Rollback(); } } } catch(Exception e){ }
Im hosting my site over at some ISP, and when i try to use INSERT or UPDATE procedure, i get this error : "SELECT command denied to user 'KidumMac'@'localhost' for table 'proc' "Which is really wired for two reasons:
A. In my code i don't reference whatsoever to the MySql databse, nor the "proc" table B. In the myPHPadmin program the queries work just fine. Any insights?
the second problem is that when i try to import my database, the tables import fine, but when it gets to import the stored procedure, it tells me that the user needs SUPER PRIVILEGES for that. what is it ?
Before I get too far down the road I just want some advice. I'm building a web app using VWD2008 and MySQL 5. I've got the membership provider stuff working fine and have an odbc connection setup which works "fine". what I've noticed is that when I configure a new sqldatasource (that will be used to provide data to a listview or something) the Advanced -> generate Insert,Update..... option is disabled. I'm assuming its because of the sql syntax difference of the square brackets issue between MS SQL Server and MySQL.
Before I start writing all my own insert and update statements does anyone know if there is a way to get MySQL and VWD to talk the same language, maybe a different connector or something. I'm using mysql-connector-odbc-3.51.15
I want to retrieve data from MySql database and display it in gridview in asp.net.I want to retrieve data from two tables which has no common fields to link.Is there any possible way to display in gridview?
I have used ASD.NET code using SQL Database for Transaction operation successfully. By changing the Database Code to interface with MYSQL an Error occurs. If I remove the Transaction Code from within the the application, it works OK by displaying the MYSQL data (Read Only) in the layout of the application. I am using Mysql Essential-4.1.22-win32 and MYSQL Connector ODBC-3.51.2. My objective is to EDIT the MYSQL Data.
protected void Button3_Click(object sender, EventArgs e) { //Create a connection to the database MySqlConnection conn = new MySqlConnection("Database=kid07025;Data Source=195.178.228.254;User Id=kid07025;Password=********"); //open the connection conn.Open(); //MySQL Query which updates the row where Anvandarnamn = Anvandarnamn (recieved from a cookie) MySqlCommand cmd = new MySqlCommand("UPDATE personer SET Information=?Information,Fnamn=?Fnamn,Enamn=?Enamn,Personnr=?Personnr,Adress=?Adress,Postnr=?Postnr,Ort=?Ort WHERE Anvandarnamn=?Anvandarnamn", conn); // Update with new text cmd.Parameters.AddWithValue("?Anvandarnamn", Request.Cookies["Anvandarnamn"].Value); cmd.Parameters.AddWithValue("?Information", TextBox1.Text); cmd.Parameters.AddWithValue("?Fnamn", TextBox2.Text); cmd.Parameters.AddWithValue("?Enamn", TextBox3.Text); cmd.Parameters.AddWithValue("?Personnr",TextBox4.Text); cmd.Parameters.AddWithValue("?Adress", TextBox5.Text); cmd.Parameters.AddWithValue("?Postnr", TextBox6.Text); cmd.Parameters.AddWithValue("?Ort", TextBox7.Text); cmd.ExecuteReader(); conn.Close(); RefreshProfile(); }
I don't know what I am doing wrong here, but the database doesn't get updated when I press the button.
PLZ find below my transaction. i feel that something is wrong in those lines especially in the insert in the table BARCOD0F .the gridview dont show the new updates .i closed the page and relaunch everthing but the updates are not considered
I have been stuck on this for a while and I can't seem to get it to work despite looking for answers in books and all over the web, so I hope perhaps you all can help me figure this out...
Here's what I'm trying to do....
I have some information in a simple product database displaying in a gridview table. One of the columns is a row of checkboxes indicating whether the item has been discontinued or not. When the row gets updated, it needs to update the checkbox value in the database.
1. It needs to be disabled until the row is getting edited.
2. Send the string value of 0 or 1 to the database when the row is updated.
Here's the code for the sql datasource and the gridview part in question...
I just moved to a new 2008 64 Bit Server. We are using MySQL, now also the 64 Bit version. Now I found out that there is a 64 Bit ODCB Driver, but not an 64 Bit Net/Connector.
Is that an issue or is the .NET Connector by default 32 and 64 Bit?
I want to use MVC 2 with MySQL database. Is it possible?because my shared hosting limits the size of SQL Server database, but there is no limit on Size of MySQL database.MySQL seems to take less disk space than SQL Server database which is costly on the Internet.
i have populated the gridview dynamically and set the ShowDeleteButton = true.. i have the delete command but i cant delete the specific row i wanted to delete..
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string ann = (GridView1.DataKeys[e.RowIndex].Values[3].ToString()); MySqlCommand update = new MySqlCommand("DELETE FROM announcement where ID = '"+ann+"'", conn);
[Code]....
how to get the values of the row that i want to delete.
I did all the instructions which are in the following link: [URL] in order to do a connection between MySQL database and ASP.NET but I did not successed. Sometimes, it told me that I have a mistake in the <asp: button> and sometimes it told me that I did a mistake in calling (addImage) method. And this is my whole code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HW5._Default" %> <script> public class DataAccess { private string _strConn = @"Driver= {MySQLODBC 3.51 Driver};SERVER=localhost;DATABASE=test1;"; private OdbcConnection _objConn; public DataAccess() { this._objConn = new OdbcConnection(this._strConn); } // This function adds the Images to database public string addImage(timestamp id, byte [] data,string extension) { string strSql = "SELECT * FROM File"; DataSet ds = new DataSet("Image"); OdbcDataAdapter tempAP = new OdbcDataAdapter(strSql,this._objConn); OdbcCommandBuilder objCommand = new OdbcCommandBuilder(tempAP); tempAP.Fill(ds,"Table"); try { this._objConn.Open(); DataRow objNewRow = ds.Tables["Table"].NewRow(); objNewRow["Extension"] = extension; objNewRow["Data"] = buffer; objNewRow["ID"] = id; ds.Tables["Table"].Rows.Add(objNewRow); // trying to update the table to add the image tempAP.Update(ds,"Table"); }.....................................
I'm trying to apply this example to my website.They use SQLServer in this link[URL]string sql = "Select * from Country Where Country_Name like @prefixText";i have to change the last part( like @prefix ) so that it wont give any errors for MySQL