paulthepaddy
Well-known member
hi guys, i am just looking for some advise which im pretty sure will make me need to change the way im doing this.
EDIT : Option Strick Will Be Used, Wont Be Using Variables Without Types
I Am trying to get my application to decide which connection string and SOL components it is going to use.
I am using the sync framework to have a local Database which can be used while no internet connection is available, then sync the database when their is a internet connection.
But i would also like to be able to connect Directly (without the sync framework) to my SQL Server when their is a connection. the problem im facing is the select Statement(it works but cant be used like it is)
is their a better way to determine whether to use SqlClient.SqlConnection OR SqlServerCe.SqlCeConnection any idea on a proper and better way to do this would be great, thanks all
EDIT : Option Strick Will Be Used, Wont Be Using Variables Without Types
I Am trying to get my application to decide which connection string and SOL components it is going to use.
I am using the sync framework to have a local Database which can be used while no internet connection is available, then sync the database when their is a internet connection.
But i would also like to be able to connect Directly (without the sync framework) to my SQL Server when their is a connection. the problem im facing is the select Statement(it works but cant be used like it is)
is their a better way to determine whether to use SqlClient.SqlConnection OR SqlServerCe.SqlCeConnection any idea on a proper and better way to do this would be great, thanks all
VB.NET:
Public Function IsConnectionAvailable() As Boolean
Return My.Computer.Network.Ping("My SQL Server")
End Function
Dim Connection
Dim CarCmd
Dim OrdCmd
Dim WDCmd
Select Case IsConnectionAvailable()
Case False
Connection = New SqlServerCe.SqlCeConnection(My.Settings.ClientImageConnectionString)
CarCmd = New SqlServerCe.SqlCeCommand("SELECT * FROM Cars WHERE Reg = @Reg", Connection)
OrdCmd = New SqlServerCe.SqlCeCommand("SELECT * FROM OrderNumbers WHERE Reg = @Reg", Connection)
WDCmd = New SqlServerCe.SqlCeCommand("SELECT * FROM WorkDone WHERE (Reg = @Reg) AND (OrderNumber = @OrderNumber)", Connection)
Case True
Connection = New SqlClient.SqlConnection(My.Settings.ServerImageConnectionString)
CarCmd = New SqlClient.SqlCommand("SELECT * FROM Cars WHERE Reg = @Reg", Connection)
OrdCmd = New SqlClient.SqlCommand("SELECT * FROM OrderNumbers WHERE Reg = @Reg", Connection)
WDCmd = New SqlClient.SqlCommand("SELECT * FROM WorkDone WHERE (Reg = @Reg) AND (OrderNumber = @OrderNumber)", Connection)
End Select
Last edited: