Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

Posted
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.

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

  • *Experts*
Posted

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.

Posted

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.

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

  • *Experts*
Posted

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.

Posted

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..

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

Posted

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.

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

  • *Experts*
Posted

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.

Posted
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.

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

Posted
Ahh fixed it CInt() should not be used, nor GetString() when its a number. Sigh. 2 hours later with something so simple.

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...