In. NET, many users use the official MySQL database. NETconnector, of course, you can also find yourself using it on the relevant website. The following articles mainly describe.. NET experience in accessing MySQL databases. Some experience has been accumulated during use: 1). NET Access to MySQL database experience: Using Parameter Parameters
In. NET, many users use the official MySQL database. NET ctor, of course, you can also find yourself using it on the relevant website. The following articles mainly describe.. NET experience in accessing MySQL databases. Some experience has been accumulated during use: 1). NET Access to MySQL database experience: Using Parameter Parameters
In. NET, many users use the official MySQL database. NET ctor, of course, you can also find yourself using it on the relevant website. The following articles mainly describe.. NET experience in accessing MySQL databases.
I have accumulated some experience in usage:
1). NET experience in accessing MySQL Databases: When submitting commands using Parameter parameters, you must replace the "@" number "? "No., this makes me confused for a day, but I just don't understand why MySQL is special, such as MS, ODP. NET for Oracle, OleDb, etc.
Use.
Example:
- string connstr=Setting.Instance().GetConnectionString("MySQL");
- MySQLConnection conn =new MySQLConnection(connstr);
- conn.Open();
- string query = "insert into myfirst(Id,Name) values(?Id,?Name)";
- MySQLCommand cmd = new MySQLCommand(query, conn);
- MySQLParameter para1=new MySQLParameter("?Id",DbType.Int32);
What should I do here? No.
- MySQLParameter para2=new MySQLParameter("?Name",DbType.String);
What should I do here? No.
- para1.Value=5;
- para2.Value="ddd";
- cmd.Parameters.Add(para1);
- cmd.Parameters.Add(para2);
- cmd.ExecuteNonQuery();
2 ). NET Access to MySQL database experience: MySQL also has reserved words. In order to provide compatibility, I must find the delimiters. It is hard to find them in the MySQL Forum. The delimiter used is ', this symbol is not a single quotation mark, but the "point" in front of number 1 on the keyboard. It really kills me.
3). NET experience in accessing MySQL Databases: The TOP function in MySQL is very simple. You only need to use "limit n" after the statement, which is much more convenient than the Rownum in ORACLE.
Using MySQL. NET ctor to access MySQL is not bad in general. Most of them are compatible with IConnection and ICommand in. NET.
PS: I don't know whether to provide a MySQLDateTime class in. NET Connector. I don't know how to use this class and how to use it. I have not found any relevant materials in China. MySQLDateTime and System. Date are not compatible yet. There are more than N related posts on the MySQL forum.
If the DateTime Field passed to MySQL using the String type Parameter, the following error is reported: Unable to Convert MySQL Date/Time value to System. DateTime.