Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open oleDB connection problem

Status
Not open for further replies.

Ronze55

MIS
Jul 9, 2004
54
US
Hi all,

I am having trouble openning my oleDB connection, I was hoping someone here could see what I am missing

here is my code:

Dim MyConn As System.Data.OleDb.OleDbConnection
Dim Mycommand As System.Data.OleDb.OleDbCommand
Dim strConn, strCommand As String
txtActivity.Text &= "file " & e.FullPath & " has been created" & vbCrLf
lblDisplay.Visible = True

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"DataSource=C:\PathName\;Extended" & _
"Properties='text;FMT=Delimited;HDR=Yes'"
MyConn = New System.Data.OleDb.OleDbConnection(strConn)
MyConn.Open()

the txt I am trying to open is a | delimited file and I have a schema.ini set up for it held within the same folder.

thanks in advance
Ronze
 
the error message I get is

<error: an exception of type: {system.invalidOperationException} occurred>

search results I found said that I was using the connection before it was opened, but the error happens on the line

myconn.open
 
What is your command doing. I see where you have dimmed strCommand but aren't using it yet. Don't you have to put it in your MyConn? Also you could put <code>Imports System.Data.OleDB</code> at the top to save some coding on the page. I will look for the specifics, however I am not sure what I delimted file is, so I might not be too much help on the subject.
 
Sorry I forgot the command example.
Code:
Imports System.Data.OleDB  (at the very top)

Dim MyConn As  New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "DataSource=C:\PathName\;Extended" & _
               "Properties='text;FMT=Delimited;HDR=Yes'")
Dim lstring As String
            lstring = "Select type.description, typeid from type order by description"
            Dim MyCommand As New OleDbCommand(lstrSQL, myConnection)
                    
            myConnection.Open()
 
yep here is how I got it to work.

Dim MyConn As System.Data.OleDb.OleDbConnection
Dim MyCommand As System.Data.OleDb.OleDbCommand
Dim strConn strCommand As String


strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Garan\;Extended Properties='text;FMT=Delimited;HDR=Yes'"
MyConn = New OleDbConnection(strConn)

strCommand = "Select * from " & e.Name
Mycommand = New OleDbCommand(strCommand, MyConn)

MyConn.Open()

thanks for your feedback, of course it was a typo... missing a space in the original

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top