Execute an MSSQL Stored Procedure against a MYSQL database
I have an MSSQL database that must get selected fields from MYSQL database and insert them on my sql database.
I have created a linked server and can perform simple queries against the MYSQL database but I am not sure how to run an MSSQL stored procedure against the MYSQL database. i'm thinking of having insert trigger on my MySQL table to call a procedure on MS
SQL that will select and insert the field i want.
Can anyone help?
Are you gathering data in fields on a form then inserting?
If so, you do not need trigger. You can insert using >NET code behind your form...
or you can use .NET to call a stored procedure that does the insert.
Example code behind form inserting a row derived from form data entry
Using SQLConnection As New MySqlConnection(connectionString)
Using MySqlCommand As New MySqlCommand()
With MySqlCommand
.CommandText = "INSERT INTO tablebirds (`AOU_NUMBER`,`BIRDNAME`) values (@AOU_NUMBER,@BIRDNAME)"
.Connection = SQLConnection
.CommandType = CommandType.Text
.Parameters.AddWithValue("@AOU_NUMBER", TextBox1.Text)
.Parameters.AddWithValue("@BIRDNAME", TextBox2.Text)
End With
Try
SQLConnection.Open()
MySqlCommand.ExecuteNonQuery()
Catch ex As MySqlException
MsgBox ex.Message.ToString
End Try End Using
End Using
As a supplement, if you want to achieve your need with C#, you could refer to the following articles, they provide a detailed tutorials and a demo in vb.net and C#.
If you want to get the return values form stored procedure, the following link you could take a look. It explains how to use MySql Stored Procedures IN, OUT, and INOUT parameters in C# code.
None
0 Points
1 Post
Execute an MSSQL Stored Procedure against a MYSQL database
Jul 15, 2015 02:01 AM|mokwenak|LINK
Execute an MSSQL Stored Procedure against a MYSQL database
I have an MSSQL database that must get selected fields from MYSQL database and insert them on my sql database.
I have created a linked server and can perform simple queries against the MYSQL database but I am not sure how to run an MSSQL stored procedure against the MYSQL database. i'm thinking of having insert trigger on my MySQL table to call a procedure on MS SQL that will select and insert the field i want.
Can anyone help?
Contributor
3462 Points
1341 Posts
Re: Execute an MSSQL Stored Procedure against a MYSQL database
Jul 15, 2015 10:42 PM|Lannie|LINK
Are you gathering data in fields on a form then inserting?
If so, you do not need trigger. You can insert using >NET code behind your form...
or you can use .NET to call a stored procedure that does the insert.
Example code behind form inserting a row derived from form data entry
Star
7980 Points
1586 Posts
Re: Execute an MSSQL Stored Procedure against a MYSQL database
Jul 29, 2015 01:03 PM|Weibo Zhang|LINK
Hi mokwenak,
Thank you for your posting.
As a supplement, if you want to achieve your need with C#, you could refer to the following articles, they provide a detailed tutorials and a demo in vb.net and C#.
http://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-stored-procedures.html
http://www.aspsnippets.com/Articles/Call-MySql-Stored-Procedure-with-Parameters-in-ASPNet-C-and-VBNet.aspx
If you want to get the return values form stored procedure, the following link you could take a look. It explains how to use MySql Stored Procedures IN, OUT, and INOUT parameters in C# code.
http://www.codeproject.com/Articles/36484/Working-C-code-for-MySql-Stored-Procedures-IN-OUT
Besides, the following links provide a CRUD demo about MySql. I think it may be useful to you.
http://www.codeproject.com/Articles/438259/Insert-Update-Search-and-Delete-CRUD-operation-usi
I hope it’s useful to you.
Best Regards,
Weibo Zhang