philprice Posted March 30, 2003 Posted March 30, 2003 Right, Just started out with webservies I'm getting: An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at NewsThingSite.NewsThing.CloseConnectionToMDB() in C:\Inetpub\wwwroot\NewsThingSite\NewsThing.asmx.vb:line 129 at NewsThingSite.NewsThing.createNewUser(String strName, String strEmail) in C:\Inetpub\wwwroot\NewsThingSite\NewsThing.asmx.vb:line 106 --- End of inner exception stack trace --- From <WebMethod(Description:="Create a new user", EnableSession:=True)> _ Public Function createNewUser() As String Dim strNewGuid As String Dim strSQL As String strNewGuid = System.Guid.NewGuid().ToString OpenConnectionToMDB() strSQL = "INSERT INTO user(GUID) VALUES('" + strNewGuid + "')" Try oCmd.CommandText = strSQL oCmd.ExecuteNonQuery() Catch strE As Exception Debug.WriteLine(strE) End Try CloseConnectionToMDB() Return strNewGuid End Function And i dont know what it means, what am i doing wrong? Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Experts* Volte Posted March 30, 2003 *Experts* Posted March 30, 2003 What does 'CloseConnectionToMDB' look like? It looks like that's where the error is happening. Quote
philprice Posted March 30, 2003 Author Posted March 30, 2003 I was using the wrong connection string, i need the path to the MDB file but i reliased, the current directory is not the one where the current files are. I need some way of getting it in ASP. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Experts* Volte Posted March 30, 2003 *Experts* Posted March 30, 2003 I think using Server.MapPath("myMDB.mdb") will get the proper path to the file in ASP, assuming it's in the same directory as the ASP file. If it's not, then Server.MapPath("myDir\myMDB.mdb") then. Quote
philprice Posted March 30, 2003 Author Posted March 30, 2003 Haha, cheers. Now another problem, im getting an error saying its "exclusivly opened by another program" or something, but its not - grr this is so frustrating. I'm using OleDB with access. sigh. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Experts* Volte Posted March 30, 2003 *Experts* Posted March 30, 2003 Are you sure you're not opening the database twice in your program (i.e. calling OpenConnectionToMDB and forgetting to close it after you're done)? Also, did Access crash while the database was open, or did you close it unusually? If it did, there's a chance that the database is locked. Look to see if there's a .ldb file in the directory with the database. Quote
philprice Posted March 30, 2003 Author Posted March 30, 2003 Okay ive fixed the open / close thing, now its telling there are errors with my sql, and its getting really annoying. System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) from INSERT INTO user (userGUID, name, email) VALUES ('ce7047f9-c3c9-414e-ac69-d48717a9bbcc', '', ''); The thing is the above statement works FINE in Access, i dont get it.. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Gurus* Derek Stone Posted March 30, 2003 *Gurus* Posted March 30, 2003 Place brackets around your table name. "User" is a reserved keyword. I believe "name" is also. Quote Posting Guidelines
philprice Posted March 30, 2003 Author Posted March 30, 2003 Thanks derek, working now, but im still frustrated, im getting a internal 500 error, from a method ive written getCatagoryByID(ID As int32), if i enter a catagory that is not there, i get a nice error, but if i do, all i get is an internal error, now the code.. strSQL = "SELECT ID, catName FROM catagory WHERE ID=" + intID.ToString OpenConnectionToMDB() myCmd.CommandText = strSQL myReader = myCmd.ExecuteReader(CommandBehavior.SingleRow) myReader.Read() myCat.catagoryID = CInt(myReader.GetString(0)) myCat.catagoryName = myReader.GetString(1) CloseConnectionToMDB() Return myCat PS Sorry about posting all this code... Ive been at this for ages and im finding it really really frustrating. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Experts* Volte Posted March 30, 2003 *Experts* Posted March 30, 2003 You should probably check to see if your DataReader's HasRows property is set to True before you try and get the data out of it. If your query didn't return anything, then you can't get data out of the reader, obviously. Not sure if that's your problem, though. Quote
philprice Posted March 30, 2003 Author Posted March 30, 2003 That helps if there is no data, i.e. a incorrect id which is cool. But it still give a 500 when there is data, this is REALLY weird, i cant actually track down the error which is really annoying. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
philprice Posted March 30, 2003 Author Posted March 30, 2003 Ahh fixed it CInt() should not be used, nor GetString() when its a number. Sigh. 2 hours later with something so simple. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Gurus* Derek Stone Posted March 30, 2003 *Gurus* Posted March 30, 2003 You might want to change those ordinals from hardcoded values into calls to GetOrdinal. This will save you time, increase readability and lessen chances of incorrect ordinal references in the future. Just a suggestion, no biggie. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.