如何将mysql数据库项目更改为SQL数据库项目? [英] How to change mysql database project to SQL database project?

查看:117
本文介绍了如何将mysql数据库项目更改为SQL数据库项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyProject是在Vb和Mysql服务器中开发的,但现在我需要将我的项目Msql更改为Sql我该怎么办?



我试过的:



我是vb和mysql的新手,所以任何人都可以帮助我吗?

解决方案

< blockquote>

我建议您查找从MySql导入数据到SQL Server的选项。 SSIS包可以做同样的事情。此外,SQL Server导入导出功能也可以执行此操作。


首先传输数据:转换MySQL数据库(MySQLToSQL) Microsoft Docs [ ^ ] shoudl帮助。



你的代码:这将取决于有多好(或多么糟糕)您已经编写了代码,以及您使用了多少MySql特定功能。



将类从MySqlConnection,MySqlCommand更改为SQL Server等效项:SqlConnection。 SqlCommand等等。

然后自己查看命令:如果你连接strgs来构建你的SQL命令:

  Dim  strCommand 作为 字符串 =   SELECT * FROM MyTable WHERE CustName ='& tbCustName.Text&   

然后转换会更容易,但您的代码容易受到攻击到SQL注入,所以你需要对你的应用程序进行大量更改以参数化所有查询。

如果你的代码使用?而是参数放置标记:

  Dim  strCommand  As  字符串 =   SELECT * FROM MyTable WHERE CustName = ? 

然后你需要用命名参数替换它:

  Dim  strCommand 作为 字符串 =   SELECT * FROM MyTable WHERE CustName = @CN 

并更改相应SqlCommand对象的Parameters集合中的名称。



之后,测试,测试测试 - 我们不知道你使用了什么MySql功能,所以这是一个识别代码失败的地方,并逐个替换每个功能的情况。



祝你好运!


MyProject is developed in Vb and Mysql server but now i need to change my project Msql to Sql what can i do?

What I have tried:

I am new to vb and mysql so any one can help me?

解决方案

I recommend you to look for the option to import data from MySql To SQL Server. SSIS package can do the same. Also, SQL Server Import Export functionality can do this as well.


Start by transfering your data: Converting MySQL Databases (MySQLToSQL) | Microsoft Docs[^] shoudl help.

THen your code: this will depend on how well (or how badly) you have written the code, and how many MySql specific features you have used.

Change the classes from MySqlConnection, MySqlCommand, and forth to their SQL Server equivalents: SqlConnection. SqlCommand, and so on.
Then look at your commands themselves: if you concatenate strigns to build your SQL commands:

Dim strCommand As String = "SELECT * FROM MyTable WHERE CustName = '" & tbCustName.Text & "'"

Then the conversion will be easier, but your code is vulnerable to SQL Injection so you need to make extensive changes to your app to parameterise all queries.
If your code uses "?" parameter place markers instead:

Dim strCommand As String = "SELECT * FROM MyTable WHERE CustName = ?"

Then you need to replace that with named parameters:

Dim strCommand As String = "SELECT * FROM MyTable WHERE CustName = @CN"

And alter the names in the Parameters collection of the appropriate SqlCommand objects.

After that, test, test test - we can have no idea what MySql features you have used, so it's a case of identifying where the code fails, and replacing each feature one by one.

Good luck!


这篇关于如何将mysql数据库项目更改为SQL数据库项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆