deloused
asked on
Changing connection in datagrid, dataadapter and dataset to point to database on the server.
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\mywebsit e.com\http docs\db\db _nts_web.m db
Am I retarded or is there an easy way to make this change?
Any help would be greatly appreciated and would save my sanity.
The connection on my server looks like this: E:\inetpub\myhost\mywebsit
Am I retarded or is there an easy way to make this change?
Any help would be greatly appreciated and would save my sanity.
ASKER
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_n ts_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(DsE ditJobBoar d1)
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.
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("...........
OleDbDataAdapter1.Fill(DsE
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.
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.md b"
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.
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_
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
String strConn = String.Format("...........