PC Review


Reply
Thread Tools Rate Thread

Database filepath got overrided by OpenFiledialog???

 
 
=?Utf-8?B?Sm9u?=
Guest
Posts: n/a
 
      2nd Apr 2005
Hi,

I am scratching all my hair out and really have no idea what is happening
with my program...

I have a dataset, and i used dataAdapter to fill the data. Everything works
fine until I run the OpenFileDialog, and select a txt file ( the file i
select has nothing do with the database).

When i try to update my dataset, It gives out
"System.Data.OleDb.OleDbException" because it is trying to find
MyDataBase.mdb where the path is the one i selected in the openFileDialoge!?!?

but the weird thing is my path for the oledb is constant, and more
importantly i dont see any connection between the two..

What should I do so that the openFiledialog won't affect the path of my
Database??

but still anyway, i can't see anything wrong in my code that my DB path will
get affected by the change of a openfiledialog...?

please if anyone can help.
Thank you very much in advance!

' Here is how i create the oledb connection
' Create OLEDB connection

Const m_OLEDB_PATH As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source= Data\MyDataBase.mdb"

Dim OleDbConn As New OleDbConnection(m_OLEDB_PATH)
m_da = New OleDbDataAdapter
m_da.SelectCommand = New OleDbCommand(m_str, OleDbConn)
Dim cmd As New OleDbCommandBuilder(m_da)

OleDbConn.Open()

' Fill DataTable in DataSet via DataAdapter
m_da.Fill(m_ds, m_tbName)
m_ds.CaseSensitive = True

OleDbConn.Close()
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      3rd Apr 2005
Hi,

You are not using a hard coded path. The connection is looking for
a database at the current directory\data\mydatabase.mdb. When you run the
open file dialog you change the current directory.

Ken
--------------------
"Jon" <(E-Mail Removed)> wrote in message
news:345F31B1-12A7-4B60-999E-(E-Mail Removed)...
Hi,

I am scratching all my hair out and really have no idea what is happening
with my program...

I have a dataset, and i used dataAdapter to fill the data. Everything works
fine until I run the OpenFileDialog, and select a txt file ( the file i
select has nothing do with the database).

When i try to update my dataset, It gives out
"System.Data.OleDb.OleDbException" because it is trying to find
MyDataBase.mdb where the path is the one i selected in the
openFileDialoge!?!?

but the weird thing is my path for the oledb is constant, and more
importantly i dont see any connection between the two..

What should I do so that the openFiledialog won't affect the path of my
Database??

but still anyway, i can't see anything wrong in my code that my DB path will
get affected by the change of a openfiledialog...?

please if anyone can help.
Thank you very much in advance!

' Here is how i create the oledb connection
' Create OLEDB connection

Const m_OLEDB_PATH As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source= Data\MyDataBase.mdb"

Dim OleDbConn As New OleDbConnection(m_OLEDB_PATH)
m_da = New OleDbDataAdapter
m_da.SelectCommand = New OleDbCommand(m_str, OleDbConn)
Dim cmd As New OleDbCommandBuilder(m_da)

OleDbConn.Open()

' Fill DataTable in DataSet via DataAdapter
m_da.Fill(m_ds, m_tbName)
m_ds.CaseSensitive = True

OleDbConn.Close()


 
Reply With Quote
 
Stephany Young
Guest
Posts: n/a
 
      3rd Apr 2005
Who's got eagle eyes today then?


"Ken Tucker [MVP]" <(E-Mail Removed)> wrote in message
news:e$Zpjn%(E-Mail Removed)...
> Hi,
>
> You are not using a hard coded path. The connection is looking for
> a database at the current directory\data\mydatabase.mdb. When you run the
> open file dialog you change the current directory.
>
> Ken
> --------------------
> "Jon" <(E-Mail Removed)> wrote in message
> news:345F31B1-12A7-4B60-999E-(E-Mail Removed)...
> Hi,
>
> I am scratching all my hair out and really have no idea what is happening
> with my program...
>
> I have a dataset, and i used dataAdapter to fill the data. Everything
> works
> fine until I run the OpenFileDialog, and select a txt file ( the file i
> select has nothing do with the database).
>
> When i try to update my dataset, It gives out
> "System.Data.OleDb.OleDbException" because it is trying to find
> MyDataBase.mdb where the path is the one i selected in the
> openFileDialoge!?!?
>
> but the weird thing is my path for the oledb is constant, and more
> importantly i dont see any connection between the two..
>
> What should I do so that the openFiledialog won't affect the path of my
> Database??
>
> but still anyway, i can't see anything wrong in my code that my DB path
> will
> get affected by the change of a openfiledialog...?
>
> please if anyone can help.
> Thank you very much in advance!
>
> ' Here is how i create the oledb connection
> ' Create OLEDB connection
>
> Const m_OLEDB_PATH As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source= Data\MyDataBase.mdb"
>
> Dim OleDbConn As New OleDbConnection(m_OLEDB_PATH)
> m_da = New OleDbDataAdapter
> m_da.SelectCommand = New OleDbCommand(m_str, OleDbConn)
> Dim cmd As New OleDbCommandBuilder(m_da)
>
> OleDbConn.Open()
>
> ' Fill DataTable in DataSet via DataAdapter
> m_da.Fill(m_ds, m_tbName)
> m_ds.CaseSensitive = True
>
> OleDbConn.Close()
>
>



 
Reply With Quote
 
Michael C#
Guest
Posts: n/a
 
      3rd Apr 2005
myFileDialog.RestoreDirectory = True

Will keep OpenFileDialog from changing the Current Directory for your app.

"Jon" <(E-Mail Removed)> wrote in message
news:345F31B1-12A7-4B60-999E-(E-Mail Removed)...
> Hi,
>
> I am scratching all my hair out and really have no idea what is happening
> with my program...
>
> I have a dataset, and i used dataAdapter to fill the data. Everything
> works
> fine until I run the OpenFileDialog, and select a txt file ( the file i
> select has nothing do with the database).
>
> When i try to update my dataset, It gives out
> "System.Data.OleDb.OleDbException" because it is trying to find
> MyDataBase.mdb where the path is the one i selected in the
> openFileDialoge!?!?
>
> but the weird thing is my path for the oledb is constant, and more
> importantly i dont see any connection between the two..
>
> What should I do so that the openFiledialog won't affect the path of my
> Database??
>
> but still anyway, i can't see anything wrong in my code that my DB path
> will
> get affected by the change of a openfiledialog...?
>
> please if anyone can help.
> Thank you very much in advance!
>
> ' Here is how i create the oledb connection
> ' Create OLEDB connection
>
> Const m_OLEDB_PATH As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source= Data\MyDataBase.mdb"
>
> Dim OleDbConn As New OleDbConnection(m_OLEDB_PATH)
> m_da = New OleDbDataAdapter
> m_da.SelectCommand = New OleDbCommand(m_str, OleDbConn)
> Dim cmd As New OleDbCommandBuilder(m_da)
>
> OleDbConn.Open()
>
> ' Fill DataTable in DataSet via DataAdapter
> m_da.Fill(m_ds, m_tbName)
> m_ds.CaseSensitive = True
>
> OleDbConn.Close()



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autologon - overrided? =?Utf-8?B?aG9zbA==?= Windows XP Embedded 2 28th Aug 2007 05:14 PM
File.Exists(filePath) always returns false in release mode if filePath contains a white space snow Microsoft VB .NET 12 14th Feb 2007 06:17 AM
user name overrided =?Utf-8?B?Q2Fyb2wgSGlsbA==?= Microsoft Frontpage 1 24th Jul 2006 11:29 PM
Storing filepath in database field ?? =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?= Microsoft ADO .NET 5 7th Apr 2006 09:31 AM
Database Filepath =?Utf-8?B?UGFwYV9DbGF1ZGU=?= Microsoft Access VBA Modules 4 20th Apr 2005 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:39 AM.