problem entering data to DB

student_help

Member
Joined
Aug 8, 2006
Messages
8
Programming Experience
Beginner
Hi

I am trying to create a window service that will read files from a selected folder in the computer. It is to read this file and store the data into a database. I think i have the code for the service part of my program wrote correctly. There is an error somewhere and i have checked the code but I am unable to see it myself. Any please would be greatly appreciated. I have included all the code. The database has been set up as a simple one table database which will be increased as i get it working. I am working with VB.net and SQL server 2005 if this is of any help. Any assistance would be greatly accepted.

VB.NET:
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.IO[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.ServiceProcess[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Service1[/SIZE]
[SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnStart([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] args() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000]' Add code here to start your service. This method should set things[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' in motion so your service can do its work.[/COLOR][/SIZE]
[SIZE=2]Timer2.Enabled = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnStop()[/SIZE]
[SIZE=2][COLOR=#008000]' Add code here to perform any tear-down necessary to stop your service.[/COLOR][/SIZE]
[SIZE=2]Timer2.Enabled = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] Savelog([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] msgs [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Diagnostics.EventLog.SourceExists([/SIZE][SIZE=2][COLOR=#800000]"MMSLog"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]Diagnostics.EventLog.CreateEventSource([/SIZE][SIZE=2][COLOR=#800000]"MMSLog"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"MMS"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] elog [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EventLog()[/SIZE]
[SIZE=2]elog.Source = [/SIZE][SIZE=2][COLOR=#800000]"MMSLog"[/COLOR][/SIZE]
[SIZE=2]elog.WriteEntry(msgs, EventLogEntryType.Error)[/SIZE]
[SIZE=2]elog.Dispose()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Timer2_Tick([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Timer2.Tick[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sConn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] conn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlConnection[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myCommand [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sqlCommand1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Qfiles() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Dim FILE_NAME As String = "C:\Queue\test.log" 'example file[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] temp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MsgStream [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] msg() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dat, hour [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mg [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] StreamReader[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mg1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mg2() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NumTel [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Message [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strDatTime [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DatTime [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DateTime[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MyLog [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] EventLog() [/SIZE][SIZE=2][COLOR=#008000]' create a new event log [/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' Check if the the Event Log Exists [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] Diagnostics.EventLog.SourceExists([/SIZE][SIZE=2][COLOR=#800000]"MMS"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]Diagnostics.EventLog.CreateEventSource([/SIZE][SIZE=2][COLOR=#800000]"MMS"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"MMSLog"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#008000]' Create Log [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]MyLog.Source = [/SIZE][SIZE=2][COLOR=#800000]"MMS"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' Write to the Log [/COLOR][/SIZE]
[SIZE=2]Diagnostics.EventLog.WriteEntry([/SIZE][SIZE=2][COLOR=#800000]"MMSLog"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"This is log on "[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](TimeOfDay), EventLogEntryType.Information)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2]sConn = [/SIZE][SIZE=2][COLOR=#800000]"Data Source=DEVELOP2;Initial Catalog=helen;Integrated Security=True"[/COLOR][/SIZE]
[SIZE=2]conn = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlConnection(sConn)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myInsertQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]Qfiles = System.IO.Directory.GetFiles([/SIZE][SIZE=2][COLOR=#800000]"C:\Queue\"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"*.log"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] Qfiles.Length - 1[/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]mg = File.OpenText(Qfiles(i))[/SIZE]
[SIZE=2]mg1 = mg.ReadLine().Trim[/SIZE]
[SIZE=2]mg2 = mg1.Split([/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]NumTel = mg2(0).Trim[/SIZE]
[SIZE=2]Message = mg1.Substring(8).Trim([/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgStream = Qfiles(i).Substring(11)[/SIZE]
[SIZE=2]MsgStream = MsgStream.Replace([/SIZE][SIZE=2][COLOR=#800000]"__"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgStream = MsgStream.Replace([/SIZE][SIZE=2][COLOR=#800000]"_"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"/"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgStream = MsgStream.Substring(7)[/SIZE]
[SIZE=2]msg = MsgStream.Split([/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]dat = msg(0)[/SIZE]
[SIZE=2]hour = msg(1).Substring(0, 8)[/SIZE]
[SIZE=2]hour = hour.Replace([/SIZE][SIZE=2][COLOR=#800000]"/"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]":"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]DatTime = [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](dat + [/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2] + hour, DateTime)[/SIZE]
[SIZE=2][COLOR=#008000]' If File.Exists(File.OpenText(Qfiles(i)).ToString) Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'File.Delete(File.OpenText(Qfiles(i)).ToString)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' End If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]Savelog(ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]conn.Open()[/SIZE]
[SIZE=2]myInsertQuery = [/SIZE][SIZE=2][COLOR=#800000]"INSERT INTO MMSIN (NumTel, Message, DatTim, LanguageID, Status ) VALUES( '"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& NumTel & [/SIZE][SIZE=2][COLOR=#800000]"', '"[/COLOR][/SIZE][SIZE=2] & Message & [/SIZE][SIZE=2][COLOR=#800000]"', '"[/COLOR][/SIZE][SIZE=2] & DatTime & [/SIZE][SIZE=2][COLOR=#800000]"', 0, 0)"[/COLOR][/SIZE]
[SIZE=2]myCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand(myInsertQuery, conn)[/SIZE]
[SIZE=2]myCommand.ExecuteNonQuery()[/SIZE]
[SIZE=2]conn.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SqlException[/SIZE]
[SIZE=2]Savelog(ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]

VB.NET:
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.ComponentModel[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Configuration.Install[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Collections[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.ServiceProcess[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] ProjectInstaller : [/SIZE][SIZE=2][COLOR=#0000ff]Inherits[/COLOR][/SIZE][SIZE=2] Installer[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] serviceInstaller [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ServiceInstaller[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] processInstaller [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ServiceProcessInstaller[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2]()[/SIZE]
[SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].New()[/SIZE]
[SIZE=2]processInstaller = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ServiceProcessInstaller()[/SIZE]
[SIZE=2]serviceInstaller = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ServiceInstaller()[/SIZE]
[SIZE=2][COLOR=#008000]' Service will run under system account[/COLOR][/SIZE]
[SIZE=2]processInstaller.Account = ServiceAccount.LocalSystem[/SIZE]
[SIZE=2][COLOR=#008000]' Service will have Start Type of Manual[/COLOR][/SIZE]
[SIZE=2]serviceInstaller.StartType = ServiceStartMode.Automatic[/SIZE]
[SIZE=2]serviceInstaller.ServiceName = [/SIZE][SIZE=2][COLOR=#800000]"MMS"[/COLOR][/SIZE]
[SIZE=2]Installers.Add(serviceInstaller)[/SIZE]
[SIZE=2]Installers.Add(processInstaller)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ServiceProcessInstaller1_AfterInstall([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, _[/SIZE]
[SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Configuration.Install.InstallEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ServiceProcessInstaller1.AfterInstall[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ServiceInstaller1_AfterInstall([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, _[/SIZE]
[SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Configuration.Install.InstallEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ServiceInstaller1.AfterInstall[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
 
I am not getting any error the information is just not being added to the database. I have not way of knowing where the problem is in the code and i looked at it several times
 
Are you sure you are not getting an exception thrown, or are you just not seeing it because it is being caught in your Try/Catch block.
Your INSERT query is quite hard to read because of the string concatenation you have used, but from a quick look numtel is supposed to be an integer, yet it looks to be a string? Maybe you have this field declared as a string, but it looks like it should be an integer from where i sit.
 
vis781 told was correct. u might have some exception in the insertion. it is better to replace "Exception" in place of "SqlException" and look at the fields u pass as the parameters. there should not be type casting. It is advisable first try in normal form replace msgbox in place of event logs and try. all the best.
with regards,
Naresh
 
Back
Top