Hi I had a visual studio 2003 project that I inherited (I am a newbie)
Now I've converted it to 2005 (.net 2) using the conversion tool. It all works fine within visual studio and stepping through it etc I can see everything getting passed as it should. So I deployed it but only to another location on my machine and setup a virtual directory on IIS to point to is so that I can get to it via IIS as opposed to vs. Again that works well. The problem that I get is when I copy everything in the deployment project in to my virtual machine and run it from there I get object reference not set to an instance of an object - grrr
Now would this really be a code issue or a configuration issue since it works fine in both the vs 2005 env and my local env just not in the virtual machine environment.
I've attached info/code below
connection string from web.config
<
connectionStrings><addname="MyConnectString"connectionString="Server=(local);Database=MyDB;Persist Security Info=True;User ID=Uzer;Password=Uzerpw"providerName="System.Data.SqlClient"/></connectionStrings>***********************************
login.aspx.vb
Private
Sub DoLogin(ByVal bLoginAsBoolean)Dim dsVerifyUserAsNew DataSetstrQueryString ="exec MyProc'"dsVerifyPW = GetDataSet(strQueryString, Application(
"SQL_Connect"))......
*********************************
MyModule.vb
Imports System.stuff
Namespace MyModule.NET
Public
Module MyModulePublicFunction GetDataSet(ByVal strSQLAsString,ByVal strSQL_ConnectAsString)As DataSetTryDim cnSQlAsNew SqlConnection(strSQL_Connect)
cnSQl.Open()
Dim dsLoadAsNew DataSetDim cmdLoadAsNew SqlCommand(strSQL, cnSQl)Dim daLoadAsNew SqlDataAdapter(cmdLoad)daLoad.Fill(dsLoad,
"ReturnedData")GetDataSet = dsLoad
cnSQl.Close()
Catch sqlexAs SqlExceptionGetDataSet =
NothingCatch exAs ExceptionGetDataSet =
NothingEndTryEndFunction*********************************************
Global.vb - on application startup
Application(
"SQL_Connect") = ConfigurationManager.ConnectionStrings("VacationConnectString").ConnectionStringHi Kity,
You are probably correct that this may be a connection string problem. Notice at the bottom of the listing that the name you are using for the connection string is VacationConnectionString, but your web.config file shows only one connection string named MyConnectString. These should be the same.
Additionally, you copied the application onto the virtual server, but the dbms server in your connection string says (local), which is the default instance of the dbms on the machine that your application is running on. (local) assumes that you have SQL Server installed on your virtual machine, but is this true? You can change (local) to the name of your server and I believe the connection string will be good.
So, two things: make sure the connection string your asking for is the one in web.config that you want and ensure the server you want to connect to is specified properly.
Joe
Hi Joe,
Thank you for your response.
The connection strings are called the same (oversight on my part when I was posting the code). I have also copied the database over to the virtual machine and confirmed that the user name and password are correct to access the database.
as far as I can tell it's failing on .Open() but only on the vm not on the development machine?
Thanks
kity
Are you sure your application is set up in IIS to run under ASP.NET 2.0?
0 comments:
Post a Comment