Reading data from a remote database - vb.net

How to read data, submit queries from vb application to a remote machine running sql server.
Please note: I have created a complete functional version of a stock control system with the database residing in the local machine. I just need the basic concept of interacting with remote databases that's all. Do we have to use sockets to read/send data ?

All you need to do is change your connection string to the remote db server and make sure that the server is actually listening. (Link assumes 2005 but 2k, 2k8+ config will be similar and easily Googled for...) You definitely DO NOT have to write special code for this.
Check out http://connectionstrings.com/ for a handy reference for the different types of connection strings in different situations.

Are we talk about .NET version of VB or old fashioned VB 6?
In .NET version of VB (VB.NET) you can use OLEDB Data adapter, ODBC Data Adapter or native .NET Data adapter depends on your needs.
See MSDN documentation enter link description here
In VB6 version, you can use ADO, OLEDB or ODBC. See documentation here: http://msdn.microsoft.com/en-us/library/aa968814(v=vs.85).aspx
I don;t recommendate to connect your application via socket by yourself because this is really bloody coding.

Related

SQL Local DB Connection on Microsoft SilverLight

Using VB.NET, I can connect to a local SQL database easily, but, trying to get more advanced graphical features, I started using SilverLight for VB.NET, and so i got this problem.
Is it possible to connect a local database, and it must be SQL, with SilverLight for VB.NET?
It must be Out Of Browser too, i'm doing a Desktop App.
If there's no really way to do it, how can i make a more beatiful system, as I don't want to make the same old windows style.
Yes, you can access a db with Silverlight. As to how, the same ways you'd do it without SL really. Personally I use EntityFramework, and create a model from my database. Then I operate on that model using the context generated.
It doesn't matter if the db is local or remote, the methods are the same - they are just connection strings after all.

How to deploy windows form application with entity framework

I am busy developing my own application, it uses a sql server database and it is connected through an entity framework. I use store procedures to insert, update, delete, select from my database.
The app works perfect on my machine even when I publish it. But my problem comes in when I try to install the app to my friend’s computer. It crashes and does not start because it cannot connect to the database.
Is there a way to publish my app with the database, without importing all the tables, store procedures and database into my friend’s pc? I just want to make it so the user just has to install the app and it works.
Your app relies on the db to work, so if you want to put it on your friends PC then you need to make the DB available somewhere, whether it be a local copy or a copy stored on a server somewhere running SQL.
How are you storing your connection string? Is it hard coded in the app or are you utilising the app.config file? To do what you're trying to do you'll need to put the connection string into the app.config file, so you can change it depending on the installation.
either that or
if you want to run your app without data, put a demo flag or something into the app.config file. Put some code into your app to check this value, if it's true then bypass the SQL code and maybe supply some demo data which is hard coded.
Does this make sense?
You could use SQL CE, but you may find it a little more difficult to 'design' your database in it if you are more used to working in SQL Server.
Have you considered SQL Server Express as an option?
On the connection string issue, you can now get the data connection wizard that Microsoft use in Visual Studio via Nuget; this makes adding a way to dynamically configure connection strings on your clients machine much easier.
Lastly, connection strings for the entity framework are different from standard SQL connection strings. Make sure that you clearly understand the differences before you start trying to configure them programmatically. Julie Lerman's excellent book on the Entity Framework explains the differences well.

vb.net 2010 Synchronize two access databases

I'm writing a desktop application that uses the main access database that will be hosted on a central server, but there will be a laptop with the app on that has an offline mode so records can be created offsite. When the laptop returns I want it needs to be synced back to the main database.
Has anybody got any pointers on a way to do this, I've briefly read about JRO but is there an alternative / better method?
Originally, I was just going to write some custom code to do this, but thought I'd check to make sure there wasn't something already out there.
Jet Replication is a perfect solution for this kind of scenario, because you can use the simplest form of it, Direct Replication, and don't need to have any outside dependencies.
Assuming your server is named \HomeOffice\ and the database is named "MainDatabase.mdb" and is stored in the \AccessDatabases\ folder, you could use this code behind a command button to synchronize from the laptop to the server:
Dim dbServer as DAO.Database
Set dbServer = DBEngine.OpenDatabase("\\HomeOffice\AccessDatabases\MainDatabase.mdb")
dbServer.Synchronize CurrentDB.Name
dbServer.Close
Set dbServer = Nothing
Now, there's no error handling, and you haven't checked for conflicts, so you'd need to do more than that, but that would get you started with the basics.
See the Jet Replication Wiki for lots more information on Jet Replication.
Access (at least through 2003) has built in capabilities to replicate a database that would be far better to use than rolling your own.
Here's some documentation on that feature: Database Replication
MS Sync Framework could be the answer, but it's a bit tricky to set up... http://msdn.microsoft.com/en-us/sync/bb821992
There is the Microsoft Sync Framework that is compatible with ADO.NET and MS SQL Server / SQL Server Compact, but that's not a small component, more like a multi-component framework.

Offline database solution for sql server

Here's task: We have an sql server database. which is hosted at our server. What we need to do is: we need to create a non-techy-users interface (basically insert/edit forms) and let these non-techy-users to install this database locally, since they are located in the areas without internet connection. Then when they're done using the database we get the data from them and inster it in our database.
The biggest concern is that it is not trivial for non-it people to install sql server. Can you please advise me what solution should I choose? Simple Access should work fine, but i really do not want to mess with it and have data conversion back and forth between engines.
Sync Framework for SQL Server: your application uses a lite weight, embedded SQL Server CE (no installation, just a couple of DLLs deployed along with your app) and the sync framework manages the synchronization with the 'mother ship' SQL Server.
Out of interest, why do they need their own installation? Can't you create a new database on your existing instance?
If you're looking for an easy way to create insert/edit forms on your database, have you considered looking at Microsoft's new LightSwitch product (currently in Beta) or Microsoft's Dynamic Data?

change Microsoft SQL Server (SqlClient) Datasource to ODBC Datasource

I use vb.net and windows form and sqlserver
I added Data Source(Microsoft SQL Server (SqlClient)) to my project. and now I need to change it to ODBC Data Source .
How Can I do That?
thanks
See these resources - you cannot simply change your SqlClient/SqlCOnnection - you need to use OdbcConnection instead:
Connecting to an ODBC Data Source Using ADO.NET
ADO.NET ODBC connection in VB.NET
ODBC is a technology several generations older than ADO.NET/SqlClient - why do you want to "downgrade" back into the dark ages?? What are you trying to achieve that you cannot do using SqlClient?? If you really must connect to a multitude of different datasources, I would strongly recommend using / investigating OleDB instead of ODBC. ODBC is really quite old, and e.g. doesn't have any 64-bit capable drivers.... OleDB does!
See the Wikipedia article on OleDB, and view impressive lists of OleDB data providers here and here for some insights.