inserting single records into database

Jan 11 2010 9:33 AM

I am a Jr. Programmer building an application for my employer.  As a part of this application, I was required to develop a piece for event logging in which certain actions were logged into a log file.  After further discussion with my employer, it was decided that it would better serve our purpose to have these events inserted into a SQL Express database so that we may log events in greater detail, and would be able to more easily search and maintain logs.

Currently, I am having difficulty understanding how datasets work.  I have read several articles, and have a certain limited understanding to be able to fill datasets. 

I created a dataset (istatusData.xsd), and I chose to have the INSERT and UPDATE statements generated for me.  Further, I chose to have it allow INSERT's and UPDATE's directly to the database instead of having to pass through the dataset.  I then checked these statements to verify their correctness (they were correct), and then tried to call the INSERT method from the code, passing the data to the dataset – or so I thought – but when I tried to insert a new record into the EventLog table, it does nothing.

I checked the variables, and the variables are correctly populated, but it still does not insert the record into the database.  I checked to make sure that the variables are strings as well.  I am sure this has more to do with not understanding how to implement this than anything else, and I am hoping someone can help me here.  Here is the code I have;

 

Friend Function WriteLog(ByVal EventType As String, ByVal EventDescription As String) As Boolean

 

                Dim Adapter As istatusDataSetTableAdapters.EventLogTableAdapter
                Dim EventDate As String = Date.Now().ToString
                Dim Success As Boolean = False



 

        Try

                Adapter = New istatusDataSetTableAdapters.EventLogTableAdapter

                Adapter.Insert(EventDate, EventType, EventDescription)

                Success = True

        Catch ex As Exception

                Throw ex

        End Try

 

Return Success

 

End Function

 

Any help would be appreciated.