Results 1 to 3 of 3

Thread: vb.net mysql load a sql file...

  1. #1

    Thread Starter
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293

    vb.net mysql load a sql file...

    has anyone used the mysqldirect .net dataprovider from www.crlab.com? i have a sqlscript file that creates about 100 tables.... now i looked at the mysqlscript component of it but it doesn't give any options to load the file...does anyone know how to load an sql file into a commandtext object? other than reading the sql file opening the file into a textstream an tossing that into a string?

  2. #2
    Lively Member
    Join Date
    Jan 2003
    Posts
    71
    I haven't used the dataprovider you mentioned, but I was able to connect to mySql using ODBC and .NET. I'm not sure I understand your question, but if the ODBC code will help, here it is.

    Code:
    Imports Microsoft.Data.Odbc
    
    Module Module1
       Sub Main()
          Dim MyConString As String
          Dim myConnection As OdbcConnection
          MyConString = "Driver={MySQL ODBC 3.51 Driver};server=localhost;database=people;" & _
                      "UID=root"
          myConnection = New OdbcConnection(MyConString)
          Try
             myConnection.Open()
    
             ' retrieve a record from a table
             Dim sql As String = "SELECT * FROM names"
             Dim da As New OdbcDataAdapter(sql, myConnection)
    
             Dim ds As New DataSet()
             da.Fill(ds, "Names")
             myConnection.Close()
          Catch MyOdbcException As OdbcException
              Console.WriteLine(MyOdbcException.ToString)
          Catch MyException As Exception
             Console.WriteLine(MyException.ToString)
          End Try
    
         
       End Sub
    End Module

  3. #3

    Thread Starter
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293

    thanks

    maybe i should have explained it better...

    i have a file called.... mysql.sql and that is where my sql command is i.e. "CREATE DATABASE TEST1" etc...

    i want to be able to load the file into my app for my data connection to use with out it messing up formating, if i put it in a string, it does....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width