Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To elaborate:</p> <p>Yes that would be the first step. The connection string should be added to your web.config under the '' element:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bf7sd233.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bf7sd233.aspx</a></p> <p>You can then read this out in your code:</p> <p><a href="https://stackoverflow.com/questions/6134359/read-connection-string-from-web-config">Read connection string from web.config</a></p> <p>The following shows a reasonably good general form for doing a database update into a SQL database based on values you're taking from a form - done in C# (which I'd recommend getting started with instead of VB.NET, for various good reasons)</p> <p><a href="https://stackoverflow.com/questions/1449776/update-database-with-values-from-textbox">Update database with values from textbox</a></p> <p>This shows how to add the connection string directly inside the code instead of from the web.config, which may be simpler for you in the first instance. This shows how to do the database update by using 'parameters' in the query (the 'variables' if you like that are denoted with @ symbols). Using parameters is basic good practise that it's worth getting used to (don't worry too much about why, but you may want to research the 'SQL injection' technique that hackers use to attack websites). This is a good starting point for you. It may seem complex at first, but ask any developer with a few years of experience and they'll tell you it's generally the way to go. As you progress in development the tempting 'out of the box' stuff provided by .NET becomes increasingly limiting, and you lose the ability to finely tune performance and other characteristics of good applications.</p> <p>The example I've given is actually still relative simple. As you develop, there are other aspects you should start bringing into your code, especially creating methods that do the bit that accesses the database (by using a SQL query) in a separate class that gets called a 'Data Access Layer' (often an intermediate layer gets used called the 'Business Logic Layer' or similar, but don't worry about that yet).</p> <p>Also the example I've given should really be packaging up some of the code in methods that give a clear indication of what the code is doing e.g. at a simpler level a method 'UpdateMachineDetails' could at least be used to encapsulate the code that updates the database.</p> <p>There are lots of tutorials if you Google for it that show you how to update a datbase 'manually' in .NET, but the form I'm giving you puts you on a good track towards best practice that is used industry-wide by software developers.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload