bound controls won't fill

D

dennist

I have a form named Authors.vb. It connects to
HasbaraSample.mdb through cnHasbaraSample. I've read in
many places that if the database isn't given a path,
ado.net first looks in the folder of the solution. This
works in other places in my application.

The connect string is
Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=HasbaraSample.mdb;

All the adapters and datasets are dragged from the data
component tab of the toolbox; after the wizard, I change
the connect string of cnHasbaraSample.

I might add that the columns include several comboboxes.
None of these are filled by the adapters that I create
for them, using cnHasbaraSample as the connect string.
This works perfectly elsewhere in my application.

None of the textboxes or comboboxes fill. Yet, I get no
error telling me the connection cannot be made.

On the other hand, I have a form POV.vb. In this form I
leave the full path in the connect string. Not
surprisingly, the comboboxes and textboxes fill perfectly.

In real life you can't deploy an application like this,
because the user may not use the same path as I do,
particularly drive H:, for example. Any help somebody
can give me will be much appreciated.

By the way, I've looked at the location of the mdb in a
message box in Authors.vb, and it is correct.

dennist


Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=HasbaraSample.mdb;
 
M

Miha Markic

Hi,

If your database lies next to executable you might construct a connection
string by yourself:
The location would be Path.GetDirectory(Application.ExeName) +
@"\HasbaraSample.mdb"
Use the string above for Data Source.

As per your program, check if Fill method actually fills datatable.
 
D

dennist

Thank you Miha. However, when I type
application.exename, I get the error exename is not a
member, and it doesn't appear in intellisense.

My database is in the solution directory, which is
undoubtedly a mistake. I will move it to the executable
directory. Do you have another suggestion?

dennist
 
M

Miha Markic

dennist said:
Thank you Miha. However, when I type
application.exename, I get the error exename is not a
member, and it doesn't appear in intellisense.

Eh, sorry, my fault (I still have flashes from VB6 ;-) ).
The correct memeber would be: Application.ExecutablePath.
My database is in the solution directory, which is
undoubtedly a mistake. I will move it to the executable
directory. Do you have another suggestion?

Ttry it now with database in executable folder.
It should work.
 
D

dennist

When I try Path.getdirectory(Application.StartupPath()) &
@"\HasbaraSample.mdb;" with the semicolon on either side
of the quotes, and whether single or double quotes, I get
improper property value.

dennist
 
D

dennist

Tried
Path.getdirectory(Application.ExecutablePath) &
@"\HasbaraSample.mdb" and a number of variations, but I
only get improper property value.

dennist
 
D

dennist

winform
-----Original Message-----
Ehmm, is this winform or aspnet app?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com




.
 
M

Miha Markic

Ok, here is the version with namespaces:
System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutableP
ath)

Make sure you are referencing System.Windows.Forms assembly.

I think you are having problems with GetDirectoryName this time. Oh well
(another my mistake).
 
D

dennist

No, Miha, it just doesn't work. I get invalid property
value no matter what variation I try.

dennist
 
D

dennist

I ended up with the statement in form load

cnHasbaraSample.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=System.IO.Path.GetDirectoryName
(System.Windows.Forms.Application.ExecutablePath) &
@\HasbaraSample.mdb;"

This doesn't cause any error. Again, however, all the
textboxes and comboboxes were empty.

dennist
 
M

Miha Markic

Hi,

Sure, it is wrong.
It should be:

cnHasbaraSample.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" +
System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutableP
ath) + "
@\HasbaraSample.mdb;"
 
D

dennist

So here is my latest statement

cnHasbaraSample.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;DataSource = " +
System.IO.Path.GetDirectoryName
(System.Windows.Forms.Application.ExecutablePath)
+ "@\HasbaraSample.mdb;"


No errors, but also an unfilled form still. A couple
questions. If I put this statement in form load, will it
overrule what I have in the property box?

What is the @ for, and why \? This I don't understand at
all. Also, why a + and not a &?

How would I format this for the property box?

thank you muchly for your time, but after handling these
tasks so easily in vb6, I am frustrated that it's so
difficult for me in vb.net. I really appreciate your
time, but it's so frustrating when the form appears with
empty textboxes and comboboxes. It should be easier.

dennist
 
M

Miha Markic

Hi,

dennist said:
So here is my latest statement

cnHasbaraSample.ConnectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;DataSource = " +
System.IO.Path.GetDirectoryName
(System.Windows.Forms.Application.ExecutablePath)
+ "@\HasbaraSample.mdb;"


No errors, but also an unfilled form still. A couple
questions. If I put this statement in form load, will it
overrule what I have in the property box?
Yes.

What is the @ for, and why \? This I don't understand at
all. Also, why a + and not a &?

+ is concatenating operator (like & at vb6 times).
Since .net uses \ for prefix for non-standard characters (example: \n would
stand for new line) you'll have problems when you want \ inside a string.
You have at least two choices: either type \\ or prefix string with @ that
means - ignore all special charactes.
How would I format this for the property box?

thank you muchly for your time, but after handling these
tasks so easily in vb6, I am frustrated that it's so
difficult for me in vb.net. I really appreciate your
time, but it's so frustrating when the form appears with
empty textboxes and comboboxes. It should be easier.

Complexity comes with power and flexibility. The .net 1.*/VS.NET 2002|3 was
meant to give a rock-solid basement.
The added features will come with Whidbey (.net 2.0).
Anyway, you might send me the form's source code or entire project so I can
check where the problem is.
 
D

dennist

Miha,

Thanks for the offer. I sent you the project. If you
didn't get it, please let me know here, or email me.

dennist
 
D

dennist

Miha,

thank you for fixing the problem for me. I'd been busy
the last couple days with medical appointments and other
things. I had to tweak a little, but the problems I set
forth in this thread are no longer with me. Thanks again.

I'm sure I'll soon be starting a thread with new problems.

dennist
 
M

Miha Markic

Hi,

dennist said:
Miha,

thank you for fixing the problem for me. I'd been busy
the last couple days with medical appointments and other
things. I had to tweak a little, but the problems I set
forth in this thread are no longer with me. Thanks again.

You're welcome.
I'm sure I'll soon be starting a thread with new problems.

I hate being idle :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top