Connecting a SQL Server database to an ASP.NET web page
I have this for Ascess in my page.aspx.vb web page:
Code:
Dim dbCn As New OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; " & "Data Source=" & Server.MapPath("\databases\CT-F1-servdatabase.mdb;"))
How do I change that when using a SQL Server database so that the path works on my localhost and on the webserver?
Thanks
Re: Connecting a SQL Server database to an ASP.NET web page
SQL Server uses SqlConnection: https://learn.microsoft.com/en-us/do....sqlconnection
Your connection string will change slightly:
Code:
' using windows authentication
Server=localhost;Database=CT-F1-servdatabase;Trusted_Connection=True;
' or using a username/password
Server=localhost;Database=CT-F1-servdatabase;User Id=changeme;Password=changeme;
Re: Connecting a SQL Server database to an ASP.NET web page
Thank you dday9,
So, can I use any SQL Server database with a static IP address or must I host the darabase on my webhosting service as a localhost?
Re: Connecting a SQL Server database to an ASP.NET web page
You can connect to a remote database, although most will require that you whitelist the IP that you are querying from so that your database server isn't wide open to the entire web.