|
-
Sep 9th, 2025, 07:42 AM
#1
Thread Starter
Fanatic Member
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
-
Sep 18th, 2025, 08:17 AM
#2
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;
-
Sep 18th, 2025, 09:50 AM
#3
Thread Starter
Fanatic Member
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?
-
Sep 18th, 2025, 12:46 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|