Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Tuesday, March 27, 2012

Connecting to SQL Server 2000 thru a VPN?

Is this even possible?
I'm coding a VB.NET WinForms app and an ASP.NET app that will access a MS
SQL 2000 Server. I've been told that when I move into a "production"
environment that I must go thru a VPN. I'm no VPN expert, but this doesn't
make much sense to me especially since the remote clients running my VB.NET
WinForms app may not have teh VPN setup.
If VPN can be used as a tunnel to access a SQL 2000 Server, can someone tell
me what needs to be in place on the client side and what would I use for a
connection string to get to the SQL 2000 Server thru the VPN.
I can't find any info on MSDN that even mentions how to connect to a SQL
2000 Server thru VPN.
Thanks, Rob.
Hi Rob,
The VPN session needs to be established prior to executing your VB.NET
app. There's not a specific connection string to do this.
Here's a sample kb article on how to setup a VPN with our firewall server ,
ISA Server.
837355 How to configure a VPN server by using Internet Security and
http://support.microsoft.com/?id=837355
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Connecting to SQL server

Hi

i'm having lots of problems connecting my application to a database. I'm using Visual Web developer 2008 (coding in VB) and trying to connect to a locally installed version SQL server Express.

what i'm trying to do is using a DropDownList box get a user to select a name. This will then automaticly run a SQL query to pull data out of the DB and into a GridView. i'm coding (in VB only) everything under the DropDownList.SelectedIndexChanged section.


the query i want to run is -

SELECT name, description, data_added, priority_id FROM task WHERE (owner_id = (SELECT owner_id FROM owner WHERE (owner_id = @.owner_id)

The owner_id field references another table (owner). Therefore i run the inner query to get the owner_id based on the selected name in the dropDownlist, then let the outer query pull out all tasks which match the result from the inner query.

my code at the moment is

Dim dsAsNew DataSet

Dim myconnectionAs SqlConnection'create a connection

'create connection to DB

myconnection.ConnectionString ="server=localhost;database=taskDB"

'create the sql command

Dim objcmdAsNew SqlCommand("SELECT name, description, data_added, priority_id FROM task WHERE (owner_id = (SELECT owner_id FROM owner WHERE (owner_id = @.owner_id)))", myconnection)

objcmd.Connection.Open()

'open the connection to DB

Dim objreaderAs SqlDataReader = objcmd.ExecuteReader

Dim daAsNew SqlDataAdapter

da.SelectCommand = objcmd

'fails here sql not allowing remote connection

da.Fill(ds)

Me.GridView1.DataSource = da

Me.GridView1.DataBind()

'close the connection to the DB

objcmd.Connection.Close()

The application fails when you select a name from the drop down box.

fails at - myconnection.ConnectionString ="server=localhost;database=taskDB"Error is "Object reference not set to an instance of an object." If i comment out this line, i get the same error but at it stopps at the objcmd.connection.open(). Strange.

Can anyone tell me what i am doing wrong? Have i setup the connection to the DB ok?

Thanks

Cj

You to use the keyword New when creating an object of class SqlConnection.

Dim myconnectionAs New SqlConnection

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx

Also, the connection string to the database doesn't seem to be right. Have a look at this and try modifying your connection string:

http://www.connectionstrings.com/?carrier=sqlserver2005