[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Changing connection in datagrid, dataadapter and dataset to point to database on the server.

Posted on 2006-06-28
8
Medium Priority
?
326 Views
Last Modified: 2012-06-21
I have a solution that runs great on my computer but I'm unsure how to make it work when I upload it to the server.  I have a web forms page with a datagrid that fills data from a dataset.  I created it using visual studio and using the create dataset wizard after I created a data adapter.  The data adapter created a data connection that points to my local machine, C:\Inetpub\wwwroot\nts\db\db_nts_web.mdb, but I need everything to point to my server connection instead.

The connection on my server looks like this:  E:\inetpub\myhost\mywebsite.com\httpdocs\db\db_nts_web.mdb

Am I retarded or is there an easy way to make this change?  

Any help would be greatly appreciated and would save my sanity.
0
Comment
Question by:deloused
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 17001093
You can always modify the connection string in page_load event of your page to point to different location. If your MDB file lives in "httpdocs\db\db_nts_web.mdb" under root folder of your virtual directory, then use Server.MapPath to get actual physical path to the file and then fix your connection string with that path.

String strConn = String.Format("............................ file={0}", Server.MapPath("~/httpdocs/db/db_nts_web.mdb"));
0
 

Author Comment

by:deloused
ID: 17002091
It's still looking for the database on my computer instead of the sever.  Now I'm getting this error:  C:\Inetpub\wwwroot\db\db_nts_web.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.  Source Error:  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

My page load event looks like this:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strConn = String.Format("............................ file={0}", Server.MapPath("~/httpdocs/db/db_nts_web.mdb"))
        OleDbDataAdapter1.Fill(DsEditJobBoard1)
        If Not IsPostBack Then
            DataGrid1.DataBind()
        End If
    End Sub

It goes back the main problem of knowing how to buile a data adapter that points to the server database instead of to my computer.  
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 17002275
You can't without creating a share on the server. Network access to file system is through shares. You will have to do following steps.

1. On your server create a share for the folder where your database is. And make sure that you give read/write access to this share to a valid windows under account who can access this share for all read/write operations. Lets say that share is "MyDatabase"
2. now fix your connection string and specify path as "\\MyServer\MyDatabase\db_nts_web.mdb"

There is major security issue with this approach because you are opening up access to your server through that share. Second you have to make sure that your ASP.Net process runs under context of user who has access to that share. MS Access database is used for local access and not a great solution for network based access.
0
 

Author Comment

by:deloused
ID: 17002389
How would it be different if I was using a SQL server database instead?  I would still have to redirect all of the project I am building on my machine to point to a database on the server right?  Would I have to create shares with SQL server as well?  

I am very new to this and had trouble getting my sql server database to test on my machine is the only reason why I went with Access.  It's a fairly small application but I would rather do it the right way than have any security issues.
0
 
LVL 23

Accepted Solution

by:
naveenkohli earned 2000 total points
ID: 17002469
Access to MSAccess database is through file system access. Consider it like using CreateFile operation on a file in your server. So for that to happen the user have to have proper authorization and all that good stuff. MSAccess is not a client-server architecture
Where as SQL Server is server thhat has a service listening on port 1433(default). When you access SQL Server using SqlConnection object, it actually sends RPC commands to SQL Server on that server and SQL Server service responds to those commands. So the real access to the database files is happening on local box itself but the commands are coming from a remote server.

Make sense?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question