Hope someone can help. I have my Access 2007 database file included in my project in my app data folder. I have been able to connect to this and display records by using a connection string in the webconfig file and programmatically creating the table to
display the data.
However, I now want to use Gridview as I need to complete a list/details exercise. So, I'm trying to add my database on the server explorer by following the add new connection wizard. However, when I select Microsoft Access Database as my Datasource in the
first box, I'm then presented with a second dialogue box (with 'Test Connection', 'OK' and 'Cancel' buttons). On this second dialogue box there is nowhere for me to Browse and add the filepath of my database file.
I've seen several video tutorials and it seems that it shouldn't be this difficult, but what I'm seeing in VS2010 is different to th tutorials!!!
I've tried this and it gives me the same dialogue box - still unable to browse to the path to select my DB file. I'm using VS2010 Professional with Access 2007. Additionally, I'm using Vista Premium with .Net Framework 4.0.
hmm..in the second dialog box, right below the Data Source, there should be a database filename box with a browse button. I can still do it...Maybe some installation issues?
Select the Gridview and go to "DataSourceId" property and select "New Data Source"
Select "Access Database"
This will create an AccessDatasource control, however this uses the Jet.OleDb.4.0 driver, which only works for .mdb files, not for .accdb (access 2007 and above) files. So either change your database into a mdb, or select "Database" instead of "Access Database",
which will create an SqlDataSource control which can connect to an .accdb file...
I made a copy of the database in .mdb format and had some success. I can now create it by configuring the datasource through the gridview options, however when I attempt to set up the SQL Statements I get the error "Object reference not set to an instance
of an object". I can bypass this and finish the dialog box. However, when I then try to edit columns or anything like that using the Gridview smart tag controls I just get the same message.
I can bypass this and finish the dialog box. However, when I then try to edit columns or anything like that using the Gridview smart tag controls I just get the same message.
Any idea what's causing this?
No, can you show us what the HTML markup is after using the wizard?
Thats definitely not the screen I see..but again I am using VS 2010 Premium. I am guessing you are missing some Oledb Providers. Also, is it a 32bit or 64bit machine? I do know that Microsoft did not have 64bit drivers for Office ...
gazrolo4
Member
165 Points
90 Posts
Access database connection using VS2010 Server Explorer
Nov 08, 2011 06:36 PM|LINK
Evening all,
Hope someone can help. I have my Access 2007 database file included in my project in my app data folder. I have been able to connect to this and display records by using a connection string in the webconfig file and programmatically creating the table to display the data.
However, I now want to use Gridview as I need to complete a list/details exercise. So, I'm trying to add my database on the server explorer by following the add new connection wizard. However, when I select Microsoft Access Database as my Datasource in the first box, I'm then presented with a second dialogue box (with 'Test Connection', 'OK' and 'Cancel' buttons). On this second dialogue box there is nowhere for me to Browse and add the filepath of my database file.
I've seen several video tutorials and it seems that it shouldn't be this difficult, but what I'm seeing in VS2010 is different to th tutorials!!!
Thanks in advance
Gareth
francissvk
Participant
1122 Points
374 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 07:45 PM|LINK
Hi,
Can you try the following and let me know the result.
Open a new project.
Add a Grid view in the aspx file
Select the Gridview and go to "DataSourceId" property and select "New Data Source"
Select "Access Database"
Then in next step it will allow to choose the db file.
if the problem persists means, pls answer me the following questions:
Which version of asp.net you are using ? (home/Pro/Enterprise)?
Thanks,
Click "…Mark As Answer" if my reply helpful to you..
A2Z DotNet
gazrolo4
Member
165 Points
90 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 07:53 PM|LINK
Hi Francissvk,
I've tried this and it gives me the same dialogue box - still unable to browse to the path to select my DB file. I'm using VS2010 Professional with Access 2007. Additionally, I'm using Vista Premium with .Net Framework 4.0.
Thanks for your help so far!
Shan.S
Member
176 Points
38 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 07:56 PM|LINK
hmm..in the second dialog box, right below the Data Source, there should be a database filename box with a browse button. I can still do it...Maybe some installation issues?
Can you paste the screenshot of both the screens?
hans_v
All-Star
35998 Points
6551 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 08:01 PM|LINK
This will create an AccessDatasource control, however this uses the Jet.OleDb.4.0 driver, which only works for .mdb files, not for .accdb (access 2007 and above) files. So either change your database into a mdb, or select "Database" instead of "Access Database", which will create an SqlDataSource control which can connect to an .accdb file...
http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET
gazrolo4
Member
165 Points
90 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 08:10 PM|LINK
Can't copy and paste onto the forum, but I've uploaded to Flickr and made public...see what you think.
http://www.flickr.com/photos/gazrolo/6326312831/
Thank you :-)
gazrolo4
Member
165 Points
90 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 08:59 PM|LINK
Hi Hans,
I made a copy of the database in .mdb format and had some success. I can now create it by configuring the datasource through the gridview options, however when I attempt to set up the SQL Statements I get the error "Object reference not set to an instance of an object". I can bypass this and finish the dialog box. However, when I then try to edit columns or anything like that using the Gridview smart tag controls I just get the same message.
Any idea what's causing this?
Thanks
hans_v
All-Star
35998 Points
6551 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 09:02 PM|LINK
No, can you show us what the HTML markup is after using the wizard?
gazrolo4
Member
165 Points
90 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 09:03 PM|LINK
Additionally, the datasource is still not displayed in the Server Explorer, so I can't see the tables etc. So something definitely still not right....
Shan.S
Member
176 Points
38 Posts
Re: Access database connection using VS2010 Server Explorer
Nov 08, 2011 09:33 PM|LINK
Thats definitely not the screen I see..but again I am using VS 2010 Premium. I am guessing you are missing some Oledb Providers. Also, is it a 32bit or 64bit machine? I do know that Microsoft did not have 64bit drivers for Office ...