I developed a web interface using ASP.NET and a database using SQL Server 2005. I created connection to database using SqlDataSource control. I also used GridView control to display data. Using Visual Studio I can see the query results using a browser on a local machine. What I want now is to access the database (queries) remotely via the internet. So I need to create a button on the web interface such that when I click the button, I should then be taken to the database. (If possible I would like to make the link secure so that when the home page is accessed, and then the button is clicked, before you access the database you supply password (or username and password)). Please give me the code for this, or step by step guide to achieving this. Many thanks.

Dani AI

Generated

A few practical points that tie the thread together for and others: do not expose your SQL Server directly to the Internet. Host the ASP.NET site on an IIS server (or a hosted ASP.NET provider) and have the site be the only public endpoint. The homepage button should simply redirect to a secured page on that site which runs queries server-side and renders the results — that keeps the database behind your server and reduces attack surface.

Deployment checklist (high-level)

  • Publish the site from VS2005 to an IIS site or host that supports ASP.NET/SQL Server.
  • Put the DB connection string in web.config and point it at the reachable SQL Server instance (use a dedicated SQL account with minimal privileges).
  • If you control the DB server and must allow remote DB connections, enable TCP/IP, open the port in the firewall, and test connectivity (see Microsoft guidance on allowing remote connections: ).

Security and practice

  • Require authentication for pages that show or edit data (Forms Authentication + login control) and serve the site over HTTPS ().
  • Do not store admin credentials in cleartext; use a least-privilege DB user and consider protecting the connectionStrings section (Connection strings and configuration files).

Small, actionable examples

protected void btnOpenDb_Click(object sender, EventArgs e)
{
    Response.Redirect("Grid.aspx");
}
<connectionStrings>
  <add name="MyConn" connectionString="Server=sqlserver.example.com;Database=MyDb;User Id=dbuser;Password=secret;" providerName="System.Data.SqlClient" />
</connectionStrings>

Troubleshooting tips: if you cannot connect remotely, check SQL Server Configuration Manager for TCP/IP, ensure SQL Browser is running for named instances, verify the instance/port and open inbound firewall rules, and confirm the DB user has proper rights. For in-browser edits (as asked), the site-side account must have UPDATE/INSERT rights and your data source must expose the update/insert commands.

Recommended Answers

All 3 Replies

to get the grid view to display the data then just bind the datasource you created to the grid (you can do it in the form designer in VS2005
To protect it so only logged in people can see it, either protect the whole page (use webconfig to protect different areas of your site) or use a login view control and place the grid in the logged in view.

I use visual studio 2005,sqlce & datagrid to view and edit data but I couldn't add or edit data in datagrid
would u pls. help me

thanks

if you have bound the datagrid to the datasource and have insert, update and delete commands in your data source just set allowedit and allowdelete = true for the gridview and it will take care of it all for you. You need something seperate to add and i use the detailsview with defaultmode set to insert and bound to the same datasource.
If you want more control over the gridview when edititng etc change each bound field into a template field and then change the item, edititem and any other templates you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.