|
-
Apr 18th, 2013, 02:08 PM
#1
Thread Starter
Member
[RESOLVED] My.Application.Info.DirectoryPath
What am I doing wrong ?
Code:
This is working
dbSource = "Data Source = C:\test\AddressBook.mdb;Jet OLEDB:Database Password=123;"
This is not
dbSource = "Data Source= (My.Application.Info.DirectoryPath & "\AddressBook.mdb;Jet OLEDB:Database Password=123;")
What ever I chang it is not working .
The file is Adressbook.mdb
Password = 123
and the file is here
My.Application.Info.DirectoryPath
-
Apr 18th, 2013, 02:14 PM
#2
Re: My.Application.Info.DirectoryPath
either you mistyped it or you are get an error at design time because your quote don't match...
try something like this
dbSource = string.format("Data Source= ({0}\AddressBook.mdb;Jet OLEDB atabase Password=123;",My.Application.Info.DirectoryPath)
or you could use IO.Path.combine(My.Application.Info.DirectoryPath,"\AddressBook.mdb") to create the full path first
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Apr 18th, 2013, 02:30 PM
#3
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
-
Apr 18th, 2013, 02:32 PM
#4
Frenzied Member
Re: My.Application.Info.DirectoryPath
 Originally Posted by BASSIES
What am I doing wrong ?
Code:
This is working
dbSource = "Data Source = C:\test\AddressBook.mdb;Jet OLEDB:Database Password=123;"
This is not
dbSource = "Data Source= (My.Application.Info.DirectoryPath & "\AddressBook.mdb;Jet OLEDB:Database Password=123;")
What ever I chang it is not working .
The file is Adressbook.mdb
Password = 123
and the file is here
My.Application.Info.DirectoryPath
not sure but think you missed a closing quote
Code:
dbSource = "Data Source= (My.Application.Info.DirectoryPath & "\AddressBook.mdb;Jet OLEDB:Database Password=123;")"
try that
-
Apr 18th, 2013, 02:40 PM
#5
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
Nope ,
Here is the code that i have found , maybe that explainse my problem .
To open the file .
Code:
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim Sql As String
Try
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
''This is working
''dbSource = "Data Source = C:\test\AddressBook.mdb;Jet OLEDB:Database Password=123;"
'' This is not
dbSource = "Data Source = (My.Application.Info.DirectoryPath & "\AddressBook.mdb;Jet OLEDB:Database Password=123;")
con.ConnectionString = dbProvider & dbSource
con.Open()
Sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(Sql, con)
da.Fill(ds, "AddressBook")
con.Close()
TextBox1.Text = ds.Tables("AddressBook").Rows(0).Item(3)
Catch ex As Exception
End Try
-
Apr 18th, 2013, 02:44 PM
#6
Re: My.Application.Info.DirectoryPath
not sure how that code even compiles.... you are missing a quote.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Apr 18th, 2013, 02:46 PM
#7
Frenzied Member
Re: My.Application.Info.DirectoryPath
Did you try my suggestion? it doesnt look like you made the change based on the code you just posted. I understand our problem.
You are missing a quote
try what I suggested please
-
Apr 18th, 2013, 02:55 PM
#8
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
billboy , I tried that
But then i get a error on Adressbook , database en password they are not declared
I think You are correct there is missing a qoute or something
-
Apr 18th, 2013, 03:00 PM
#9
Re: My.Application.Info.DirectoryPath
me shakes his head and points to post #2
Last edited by kebo; Apr 18th, 2013 at 07:29 PM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Apr 18th, 2013, 03:09 PM
#10
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
Kebo ,
I tried that but it is not working.
I don't understand what You mean by that.
-
Apr 18th, 2013, 03:14 PM
#11
Re: My.Application.Info.DirectoryPath
The String.Format method will create a string for you from text and variables. In the following line....
Code:
dbSource = string.format("Data Source= ({0}\AddressBook.mdb;Jet OLEDBatabase Password=123;",My.Application.Info.DirectoryPath)
My.Application.Info.DirectoryPath is a variable that replaces the {0} in the beginning of the string
Code:
dim s as string = "vb.net"
dim s2 as string = String.Format("{0} is ok",s)
will result in
s2 = "vb.net is ok"
Did you try it?
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Apr 18th, 2013, 07:21 PM
#12
Frenzied Member
Re: My.Application.Info.DirectoryPath
Please dont say things like "I tried it it dosnt work"
post what you tried, often times you may think you tried it correctly but made a mistake or were confused about something(trust me being new myself i have done that a thousand times)
so post your new code and we can see if mistakes were made
did you try kebos suggestion in post#2, that is a cleaner way of doing what you want and less prone to errors with quotes and such
again post the code you tried and the erro you get and where the error occurs
-
Apr 19th, 2013, 01:46 AM
#13
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
Oke sorry,
Here is my latest try
Code:
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim Sql As String
Dim s As String = "My.Application.Info.DirectoryPath"
Dim s2 As String = String.Format("{0}\AddressBook.mdb;Jet OLEDBatabase Password=123;", s)
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = String.Format("Data Source= ({0}\AddressBook.mdb;Jet OLEDBatabase Password=123;", My.Application.Info.DirectoryPath)
con.ConnectionString = dbProvider & dbSource
con.Open()
Sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(Sql, con)
da.Fill(ds, "AddressBook")
con.Close()
TextBox1.Text = ds.Tables("AddressBook").Rows(0).Item(3)
I get a error now
Code:
Could not find installable ISAM file.
-
Apr 19th, 2013, 01:56 AM
#14
Re: My.Application.Info.DirectoryPath
In a connection string you use |DataDirectory| to represent the program folder.
Code:
Dim connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AddressBook.mdb;Jet OLEDB:Database Password=123"
As there is no 64-bit version of the Jet OLE DB provider, make sure that your project targets the x86 platform or it will not work on 64-bit systems.
-
Apr 19th, 2013, 02:20 AM
#15
Thread Starter
Member
Re: My.Application.Info.DirectoryPath
This is working , thanks You all for your help
Code:
dbSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AddressBook.mdb;Jet OLEDB:Database Password=123"
-
Apr 19th, 2013, 12:24 PM
#16
Frenzied Member
Re: My.Application.Info.DirectoryPath
great please rate and mark your thread as resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|