MySQL and SQL Server data acquisition

Source: Internet
Author: User

Because of the project requirements, a. NET MVC login registered something site must discard SQL Server data to use the MySQL database, so I encountered some problems and found the corresponding solution,

Because SQL Server differs from MySQL's data engine, you must refer to a third-party library.

The first: Use MySQLDriverCS.dll, the third-party library.

First of all, I from a software download site in the country to scare the DLL, copy the reference, found debugging, he will error, said that has loaded DLL, but can not find the PDB file, before also encountered this problem, but did not solve, this is ready to solve this problem, I tried to re-copy the reference, Later run the program up he also want to tell me also want a DLL, so I went down that DLL, reference, found and no way to quote, error is not a valid DLL file, a lot of things, got two disappeared found and eggs, still can't solve the problem. So I gave up this DLL. So I took advantage of some degree of how to use MySQL database, found the second method.

Second: Still use third-party library, MySql.Data.dll this library. This time is not so much, I went directly to the official website DLL, and then directly copy, reference, specific tutorials you see how others, I am not here to focus on this.

The Third Kind: Through ODBC access MySQL database, specifically how to do I did not study, should be good to get.

The point of this article is that when I use C # with SQL Server database, there is a SqlCommand ExecuteNonQuery method that is used to get the return data to determine whether the execution succeeds, and then when I instantiate the SqlCommand object, invoke the method inside,

I used to write this all the time with SQL Server. The code is almost like this (see below):

The above code defines a SqlCommand object, then instantiates the object, invokes the object inside the ExecuteNonQuery method, and gets the number of affected rows returned to the SQL statement execution is generally handled like this.

But when I use the Mysqlcommand is different, I use the same way he always reminds me that I did not find the object, prompt error, code repeated view has not seen what the problem, I began to think is my statement of the problem, has been a certain degree of search statements, Then I changed a way to see how someone else's code was written, and then I saw that someone else's code didn't declare the Mysqlcommand object, directly declaring a var type, and then instantiating the Mysqlcommand object directly. Then I changed the code. (see picture below), so the inexplicable is good. But I still didn't find the reason, so I wanted to write this essay record.

As for the reason I do not struggle, but I hope that the great God help me to correct, just what reason, because I feel my basic knowledge is too bad. Seek the Great God, this article pure hand, reproduced please indicate the source

MySQL and SQL Server data acquisition

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.