How To Insert Data To MySQL Database
Jan 23, 2011i am trying to use MySQL 5 and asp.net 4
i succeed withe the linking and display the data from MySQL DB but the problem is within the DML Commands !!
[Code]....
i am trying to use MySQL 5 and asp.net 4
i succeed withe the linking and display the data from MySQL DB but the problem is within the DML Commands !!
[Code]....
Insert Edit Update Delete (CRUD) in GridView using MySQL Database?
View 1 RepliesIm 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 ?
I am trying to insert html pages to MySQL with my Asp.NET project but i am getting error; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'de Osman patlaması', '', '<div style="text-align: center"> <img src="/i' at line 1
How can i fix that problem my server side code is;
MySqlConnection myCon = new MySqlConnection();
myCon.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.Text;
string query = @"INSERT INTO `test`.`posts` (`id`, `author`, `title`, `description`, `content`, `ispublished`, `iscommentsenabled`, `pubDate`, `lastModified`, `raters`, `rating`, `slug`, `tags`, `categories`) VALUES (NULL, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')";
query = String.Format(query, p.author, p.title, p.description, p.content, p.ispublished, p.iscommentsenabled, p.pubDate, p.lastModified, p.raters, p.rating, p.slug, p.tags, p.categories);
cmd.CommandText = query;
cmd.Connection = myCon;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();..............
I have a requirement that I need to read an excel sheet using asp.net/C# and insert all the records into mysql table.The excel sheet consists of around 2000 rows and 50 columns. Currently,upon reading the excel records ,I am inserting the records one by one using a prepare statement into mysql table.But its taking around 70 secs to do so because of the huge data.
I've also thought of creating a new datarow, assigning values to each cell,adding the resulting datarow to datatable and finally calling dataadapter.update(...).But it seems to be complex because I got around 50 columns and hence I'll have to assign 50 values to the datarow.
Actually i need to transfer data from one table to another table in mysql with codition of Time.for example i need to transfer data at 10.00am when user login at 10.00am it must be insert into another data table.. if anybody know time control
View 2 RepliesWhy does a very simple script which inserts 26,000 records into a mysql database (myisam, no transactions) take 13 seconds in the php implementation, and then 35-50 seconds using mono+mysql connector? I thought asp.net was faster than php? Could the problem be the mono mysql connector is "platform independent", so the performance just stinks? or does asp.net suffer more overhead than php when it comes to executing each query? Aren't there any native linux binaries for mysql connector for mono that may be faster?
View 1 RepliesI developed a web site more then a year ago with .net2.0/c#/mssql 2005. it works fine but i was asked to replace mssql with mysql.
I wrote a class to complete data access works (unfortunately, I didnt use nhibernate or other data access tools :((
I edited the class to use System.Data.Odbc objects rather than System.Data.SqlClient.
It works fine in selecting data but not manipulating data. when i try to insert new data it adds null data for all fields in the table.
in debug mode, i noticed that it might be caused by OdbcParameter but not sure.
My code is to update a record if it already exists in database else insert as a new record. My code is as follows:
protected void Button3_Click(object sender, EventArgs e)
{
OdbcConnection MyConnection = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testcase;User=root;Password=root;Option=3;");
MyConnection.Open();
String MyString = "select fil_no,orderdate from temp_save where fil_no=? and orderdate=?";
OdbcCommand MyCmd = new OdbcCommand(MyString, MyConnection);
MyCmd.Parameters.AddWithValue("", HiddenField4.Value);
MyCmd.Parameters.AddWithValue("", TextBox3.Text);
using (OdbcDataReader MyReader4 = MyCmd.ExecuteReader())
{
//**
if (MyReader4.Read())
{
String MyString1 = "UPDATE temp_save SET order=? where fil_no=? AND orderdate=?";
OdbcCommand MyCmd1 = new OdbcCommand(MyString1, MyConnection);
MyCmd1.Parameters.AddWithValue("", Editor1.Content.ToString());
MyCmd1.Parameters.AddWithValue("", HiddenField1.Value);
MyCmd1.Parameters.AddWithValue("", TextBox3.Text);
MyCmd1.ExecuteNonQuery();
}
else
{
// set the SQL string
String strSQL = "INSERT INTO temp_save (fil_no,order,orderdate) " +
"VALUES (?,?,?)";
// Create the Command and set its properties
OdbcCommand objCmd = new OdbcCommand(strSQL, MyConnection);
objCmd.Parameters.AddWithValue("", HiddenField4.Value);
objCmd.Parameters.AddWithValue("", Editor1.Content.ToString());
objCmd.Parameters.AddWithValue("", TextBox3.Text);
// execute the command
objCmd.ExecuteNonQuery();
}
}
}
I am getting the error as: ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.1.51-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,orderdate) VALUES ('04050040272009',' &' at line 1
The datatype for fields in table temp_save are:
fil_no-->INT(15)( to store a 15 digit number)
order-->LONGTEXT(to store contents from HTMLEditor(ajax control))
orderdate-->DATE(to store date)
How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ but it does not work with mysql database
View 2 RepliesI have grid view in ASP.Net 3.5. I need to add multiple blank rows in a gridview and then have to save them in database. How can I do that in most simplest way?
View 7 RepliesI have an excel file which gets updated every 10 seconds through an automated process. I need excel data to be updated in MY-SQL database which is located on a remote server.
How do I do that?
I have thought of following option:
1) Every 11 seconds, an Excel macro will run and will "Save as" excel as CSV file. (not sure whether this can be done by macro...just thinking)
2) This CSV file we will FTP to remote server using Windows Service.
3) On remote server, we will parse the csv file and Update MYSQL database.
Is this approach fine? Or do you have a better approach which requires less time to update the database?
I am trying to set up a server on my own pc to test programs i am making, however i keep running into an issue with Access databases saying that it's not registered on my local machine or something like that. So i was thinking of trying MySql instead, but i cant figure out how to set up a database to run on my pc. I have done it using MySql Workbench before to connect to a database set up on my schools server, but that was an already set up database that they created for each student. I want to know how to set one up on my own pc. how to set this up? I tried the server administration section of MySql Workbench but it seems to ask for an existing database already.
View 1 RepliesI am importing Excel file data into gridview control,i want to insert same grid view data into mysql database.I have plenty of excel files in my root folder, these excel files always update with new data.
View 3 RepliesI have a MySQL database, and I'm currently creating an ASP.NET website to update data in it. I'm currently having trouble changing the data with GridView. Reading through various posts on this site, i think I've got a problem with binding the data, but I'm not sure how to accomplish this with MySQL database. My c# code is as follows:
[Code]....
My asp code is as follows:
[Code]....
At the moment I'm getting an error about the "trash" data, it's an Int32 field, but I'm not sure how to handle that.
what is the uniqueidentifier data type equivalent in mysql
View 1 Repliesis there ny data type of date which can hold the date only.....coz i have a field of date in which i have write date manually... i have taken the datatype as DateTime.... and its showing "incorrect datetime value"..
View 1 RepliesI 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...
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlDataMaster %>"
ProviderName="<%$ ConnectionStrings:sqlDataMaster.ProviderName %>"
SelectCommand="SELECT ID, ProductName, ListPrice, Discontinued FROM Products"
UpdateCommand="UPDATE Products SET ProductName=@ProductName, ListPrice=@ListPrice, Discontinued=@Discontinued WHERE ID=@ID"
DeleteCommand="DELETE FROM Products WHERE ID=@ID">
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="ListPrice" Type="Double" />
<asp:Parameter Name="Discontinued" Type="Boolean" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="ListPrice" Type="Double" />
<asp:Parameter Name="Discontinued" Type="Boolean" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" AllowSorting="True"
DataSourceID="SqlDataSource1" CellPadding="3"
GridLines="Vertical" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px"
DataKeyNames = "ID">
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="true" ShowDeleteButton="true" />
<asp:BoundField DataField="ID" HeaderText="Product ID" SortExpression="ID" ReadOnly="true" />
<asp:BoundField DataField="ProductName" HeaderText="Product Name"
SortExpression="ProductName" >
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="ListPrice" DataFormatString="{0:c}"
HeaderText="Unit Price" SortExpression="ListPrice" />
<asp:TemplateField HeaderText="Discontinued" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox id="Discontinued" runat="server"
Checked='<%#Convert.ToBoolean(Eval("Discontinued")) %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
Here's a live version for you to look at...
http://homeworksite.mythandmagicstudios.com/homework4/proj3/default.aspx
In my mysql I have an autoincrement id , whenever I add a new row into database I need to store this id in other table, so how to get this autoincrement Id back?
View 4 Repliesthe problem is that it will insert a new record in a mysql table, I have already done the mapping of the mysql db and I have already done tests returning data and everything works. Now I read from a file, where there are queries written, I have them run me back and the result of true or false based on the final outcome of single query written to the file. Txt; I did this:
using (var w = new demotestEntities ())
(
foreach (var l listaqueri)
(
var p = we.CreateQuery <category> (l);
we.SaveChanges ();
result = true;
)
)
but it does not work, I sense that it returns no errors, but neither the result given written in the query. txt file is as follows: INSERT INTO category (id, name) VALUES (null, 'test2')
Can I create an ADO.NET Entity Data Model for a MySQL database using Visual Web Express 2010? If yes, are there any documentation or tutorials?
View 1 RepliesI have Mysql database.In that some records status is New.now,I bind database table to Listview(asp) control.
What's my problem is,the New status records(from Mysql database) text in Listview(after binding) is visible in
bold format.
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.
View 8 RepliesI am trying to insert a record into a MySQL table, but the operation fails without generating any error. Here is what I have:
Code:
Try
n = taProject.InsertNewProject(pname, descr, idManager, startdate, tenddate, client, disable)
Catch ex As Exception
Beep()
End Try
[code]....
I am not passing idProject, which is the primary key, and set to autoIncrement..How can I get any diagnostic output from the insert attempt to indicate what the error is?
I have some data which is in mySQL, i am not familier with mySQL, i would like to transfer all the data from MySQL to SQL Server database,
View 11 Replies