| | |
SQL express on a remote machine
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
Hullo daniwebbers!!
I have created a little cd database at home on my home network. And I want my machine to act as the server. I want the other pcs, i.e my sister's and mom's which are connected to my network to access it, and be able to change and update stuff. So they can add and remove music entries.
But I'm confused, has anyone used SQL express on a remote machine. If so pleasse give me a helping hand. Help.
Thanx.
I have created a little cd database at home on my home network. And I want my machine to act as the server. I want the other pcs, i.e my sister's and mom's which are connected to my network to access it, and be able to change and update stuff. So they can add and remove music entries.
But I'm confused, has anyone used SQL express on a remote machine. If so pleasse give me a helping hand. Help.
Thanx.
This knowledge base article takes you through the steps of configuring the server. Once you have it set up, you should be able to connect normally from another machine on the network.
When you connect through .NET, be sure to include the server machine name. A lot of examples use ".\SQLEXPRESS" or "(local)\SQLEXPRESS" instead of "<server>\SQLEXPRESS". The connection string should look like this.
I'll attach a little program that you can use to build connection strings and test the connection with your database.
When you connect through .NET, be sure to include the server machine name. A lot of examples use ".\SQLEXPRESS" or "(local)\SQLEXPRESS" instead of "<server>\SQLEXPRESS". The connection string should look like this.
VB.NET Syntax (Toggle Plain Text)
"Server=<server>\SQLEXPRESS;User ID=<username>;password=<password>;Database=<databasename>;Persist Security Info=True"
The truth does not change according to our ability to stomach it.
That's up to you. I like to put it in a static property for a Program class that I make for stuff that needs to be available across the entire application. Other stuff in that class would be the entry point, error logging and user notifications, or cached data.
When the program loads I'll read the connection string from XML or a database, or call the ConnectionBuilder to make one for me using a public method from the same class. Then you can get to it from anywhere in the application by saying Program.ConnectionString. And if you use the ConnectionBuilder you can save it somewhere so that you don't have to rebuild the connection string every time.
vb.net Syntax (Toggle Plain Text)
Public Class Program Private _connectionString As String Public ReadOnly Property ConnectionString As String Get Return _connectionString End Get End Property Public Sub LoadSettings() ' Read the connection string from some storage medium ' Decrypt the connection string if necessary End Sub Public Sub SaveSettings() ' Save the connection string to some storage medium ' Encrypt it if you don't want it to be plain text End Sub End Class
The truth does not change according to our ability to stomach it.
Ok I tried to change the connection string but it won't let me. I can't edit it.
This is where I am stuck.
click_me
This is where I am stuck. click_me
You don't edit it during the wizard, it saves the string in all of the generated code that gets written after you finish the wizard. But all of that stuff makes working with connections harder if you don't already know how it wokrs. You should do it manually instead so that you know how everything works and then do the generated code if you want to later. 
You can boil it all down into a few lines manually while the generated code cranks out hundreds of lines of extra stuff. If you use a wizard, you're making generated code and life starts to suck.

You can boil it all down into a few lines manually while the generated code cranks out hundreds of lines of extra stuff. If you use a wizard, you're making generated code and life starts to suck.

VB.NET Syntax (Toggle Plain Text)
using System; using System.Data; using System.Data.SqlClient; public class DataManager { public static DataTable ExecuteSql( connectionString ) { try { // A connection gets you access to the database. using ( SqlConnection con = new SqlConnection( connectionString ) ) { // A command has the query stuff for the database. using ( SqlCommand cmd = new SqlCommand() ) { // Always open the connection. :) // If the connection object is in a using statement, the Dispose // method closes it automatically. con.Open(); // Set up the command and attach it to the connection. cmd.Connection = con; cmd.CommandText = "select * from mytable"; // A data adapter links commands to disconnected datasets. using ( SqlDataAdapter da = new SqlDataAdapter( cmd ) ) { // Put the resultset in a data table and you're done! using ( DataTable result = new DataTable() ) { da.Fill( result ); return result; } } } } } catch ( Exception ex ) { // Log the error throw; } } }
The truth does not change according to our ability to stomach it.
![]() |
Similar Threads
- VB.Net and sql server connection (VB.NET)
- built in login and createuser wizard but for a remote SQL database? how to change? (ASP.NET)
- Sql Express 2005 Installation error in Vista (Windows Vista and Windows 7)
- SQL Server not running. (VB.NET)
- Connecting to database (VB.NET)
- Modifying the Remote machine IE Favorites List By Visual Basic (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Error Closing App..
- Next Thread: How to call a class
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year






