473,378 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Need some help please on creating Service for PABX Data Dumper Using VB 2005

Hello everyone. I'm creating windows service application to capture
data from my PABX, and send the data to sql server. My question is how
could my application know when that PABX is sending data and not? I get
really confused here. Please check my code and give me some idea or
clue or help please :). Thanks in advance. My code is like this:

Dim DBConnection As SqlConnection
Dim WithEvents SPConnection As SerialPort = New
System.IO.Ports.SerialPort
Dim RawData As String

Private Sub ConnectingDB()

Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False; " + _
"Initial Catalog=PABX;Data Source=USER/SQL2000"
DBConnection = New SqlConnection(connectionString)

DBConnection.Open()

End Sub
Private Sub SPConnection_DataReceived(ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles SPConnection.DataReceived
RawData = SPConnection.ReadExisting()
SavetoDB()
End Sub

Private Sub SavetoDB()
Dim sqlTran As SqlTransaction = DBKoneksi.BeginTransaction()
Dim command As SqlCommand = DBKoneksi.CreateCommand()
command.Transaction = sqlTran

Try
command.CommandText = _
"INSERT INTO SampleTable VALUES(RawData)"
command.ExecuteNonQuery()
sqlTran.Commit()
Console.WriteLine("Both records were written to database.")
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.WriteLine("Neither record was written to
database.")
sqlTran.Rollback()
End Try

End Sub

Protected Overrides Sub OnStart(ByVal args() As String)
With SPConnection
.PortName = "COM1"
.BaudRate = 57600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
End With
SPConnection.Open()
ConnectingDB()
End Sub

Protected Overrides Sub OnStop()
SPConnection.Close()
DBConnection.Close()
End Sub

Jun 14 '06 #1
0 1071

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cobra Pilot | last post by:
I can't figure out why these three snippits of code are not equivalent.. Can someone show me the correct way to do this... (Cut and paste sample code follows). @tbl is array of array refs: ...
0
by: Eric | last post by:
I've got a weird problem, regardless of how often I enter: perl -MCPAN -e 'install "Data::Dumper"' I never get a message telling me that it is up-to-date. It will always try to reinstall even...
1
by: Steven | last post by:
Hi all My problem is a little lengthy. But please help me. In my application, ADO.NET DataSet object is not getting constructed in the Web Service Web Method called by the Windows Application...
14
by: horos | last post by:
hey all, I'm a heavy perl user, not so much a java script user, and was wondering... perl has an extremely nice utility called Data::Dumper, which allows you to dump out the contents of an...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
0
by: Jeova Almeida | last post by:
Hello, I created a simple web service for testing purpose in Visual Studio 2005: <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="WSTest" %> using System;
0
by: Jeova Almeida | last post by:
Hello, I created a simple web service for testing purpose in Visual Studio 2005: <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="WSTest" %> using System;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.