Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Problem to reload a dump file to a database via ExecuteNonQuery. Visual Studio 2005, MySQL Server and .NET Connector. (1 reply)

$
0
0
The .NET Connector is working great to a remote Linux MySQL Server.
But I have a problem with this for example:

Dim conn As New MySql.Data.MySqlClient.MySqlConnection
Dim myConnectionString As String

myConnectionString = "server=testsystem;" _
& "uid=tester;" _
& "pwd=test;" _
& "database=test;"

Try
conn.ConnectionString = myConnectionString
conn.Open()

Catch ex As MySql.Data.MySqlClient.MySqlException
MessageBox.Show(ex.Message)
End Try


Dim strSQL As String = "drop database test;"
Dim myCommand As MySqlCommand = New MySqlCommand(strSQL, conn)

Try
myCommand.ExecuteNonQuery()

Catch ex As Exception
MsgBox("Fehler beim Löschen der DB: " & ex.ToString)
End Try

strSQL = "create database test;"
myCommand = New MySqlCommand(strSQL, conn)
Try
myCommand.ExecuteNonQuery()


Catch ex As Exception
MsgBox("Fehler beim Anlegen der DB: " & ex.ToString)
End
End Try

strSQL = "use test;"
myCommand = New MySqlCommand(strSQL, conn)
MsgBox(strSQL)
Try
myCommand.ExecuteNonQuery()

Catch ex As Exception
MsgBox("Fehler beim Verwenden der DB: " & ex.ToString)
End

End Try


'Does not work!
Dim dumpfile As String = "dbdump.sql"
Dim DumpTarget As String = "/test/dumps/" & dumpfile
strSQL = "source " & DumpTarget & ";"


myCommand = New MySqlCommand(strSQL, conn)
Try
myCommand.ExecuteNonQuery()

Catch ex As Exception
MsgBox("Fehler beim Einspielen des Dumps: " & ex.ToString)
End
End Try

This is working fine, but not the last ExecuteNonQuery with the source command (see http://dev.mysql.com/doc/refman/5.6/en/reloading-sql-format-dumps.html )

This throws a MySqlException: You have an error in your SQL Syntax;

I have tried some other syntax, but failed.
Is this command (source) not working with ExecuteNonQuery?
What can I do to make this work?

Viewing all articles
Browse latest Browse all 1451

Trending Articles