|
hi,
i have written the code as shown below,i want to read data from serial port and let it display on the textbox.I compiled the codes and there's nothing wrong with the codes.However,i am not able to read incoming data.Could you help me take a look at my codes?
Public Class Form1
Dim dset As New DataSet
Dim dAdapter As OleDb.OleDbDataAdapter
Dim ConObject As New OleDb.OleDbConnection
Dim TotalRows As Integer
Dim Sel As String
Private Sub OpenPORT1(ByVal PortNum As Integer)
If SerialPort1.IsOpen Then
SerialPort1.Close()
End If
SerialPort1.PortName = "COM" + Convert.ToString(PortNum)
SerialPort1.BaudRate = 38400
SerialPort1.Parity = System.IO.Ports.Parity.None
SerialPort1.StopBits = System.IO.Ports.StopBits.One
SerialPort1.RtsEnable = True
SerialPort1.Open()
End Sub
Private Sub ResetBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetBtn.Click
Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)
Dim counter As Integer
TextBox1.Clear()
display_box.Clear()
RS232.Clear()
TotalRows = dset.Tables("EMSdatabase").Rows.Count
If TotalRows > 25 Then
For counter = 25 To TotalRows - 1
dset.Tables("EMSdatabase").Rows(25).Delete()
dAdapter.Update(dset, "EMSdatabase")
Next counter
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConObject.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\pohyingling\Desktop\development of an enviroment monitoring sys\EMS\EMS\EMSdatabase.mdb"
ConObject.Open()
Sel = "SELECT*FROM ems"
dAdapter = New OleDb.OleDbDataAdapter(Sel, ConObject)
dAdapter.Fill(dset, "EMSdatabase")
ConObject.Close()
TotalRows = dset.Tables("EMSdatabase").Rows.Count
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If InStr(display_box.Text, "") Then
dAdapter.Update(dset, "EMSdatabase")
End If
End Sub
Private Sub StartBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartBtn.Click
Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsNumeric(RS232.Text) = False Then
RS232.Text = InputBox("Enter waspmote COM port no'")
Else
Call OpenPORT1(Convert.ToInt16(RS232.Text))
display_box.Text = SerialPort1.ReadExisting
End If
End Sub
Private Sub DisplayDatabaseBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayDatabaseBtn.Click
Dim Counter As Integer
Dim Data As String
TextBox1.Clear()
TotalRows = dset.Tables("EMSdatabase").Rows.Count
For Counter = 0 To TotalRows - 1
Data = dset.Tables("EMSdatabase").Rows(Counter).Item("Data:")
TextBox1.Text = TextBox1.Text + Data + vbNewLine
Next Counter
End Sub
Private Sub deleteBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deleteBtn.Click
Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)
End Sub
End Class
|
|
|
|
|
dusk85 wrote: Call OpenPORT1(Convert.ToInt16(RS232.Text))
display_box.Text = SerialPort1.ReadExisting
serial data needs time to get transmitted; you opening the port and getting "all the data" right away results in no data at all. No surprise here. You need either a fixed delay (say 1 second to receive up to 1000 bytes at 9600 Baud), a timer-based approach that polls the port (i.e. a repetitive Read rather than a single ReadExisting), or best an event driven approach (see SerialPort.DataReceived). I suggest you read up on SerialPort class and some examples.
|
|
|
|
|
dusk85 wrote: and there's nothing wrong with the codes
If this was the case, you wouldn't have a problem and you wouldn't be here, would you?
Luc is correct. Your code is reading all of the data that is available at the moment ReadAllBytes is called. It does NOT wait around for any remaining bytes to show up until there is a complete response. After all, how could it possibly know what makes up a complete response?
Your code has to be rewritten to get the data in chunks, whenever they become available, building a response, chunk-by-chunk, until YOUR CODE determines that it has received a complete responce, then it can send that response to the code that appropriately handles it.
|
|
|
|
|
I am getting the following error message "Missing parameter values." when I am trying to print directly to the printer. Below is my code. Works perfect if I want to view on screen but get the above error message when I try to print direct to my printer. If I did not have any parameter code etc, prints no bother to printer.
Dim cr As New ReportDocument
Dim param1Fields As New ParameterFields
Dim param1Field As New ParameterField
Dim param1Range As New ParameterDiscreteValue
cr.Load("c:\MyReport.rpt")
param1Field.ParameterFieldName = "PassedParameter"
param1Range.Value = 123456
param1Field.CurrentValues.Add(param1Range)
param1Fields.Add(param1Field)
CrystalReportViewer1.ParameterFieldInfo = param1Fields
'View Report
'CrystalReportViewer1.ReportSource = cr
'Print straight to printer
cr.PrintToPrinter(1, False, 0, 0) '(1, False, 0, 0)
modified on Friday, November 26, 2010 5:21 AM
|
|
|
|
|
IS_Assessor wrote: CrystalReportViewer1.ParameterFieldInfo = param1Fields
I suspect your problem is here - you are assigning the parameter to the Viewer object, not the report document.
|
|
|
|
|
Hi,
Thanks for replying.
I tried the following but still got the same message.
cr.DataDefinition.ParameterFields("PassParameter").ApplyCurrentValues("123456")
I agree I was assigning the parameter to the viewer object but I just cannot seem to get the syntax right to assign to cr.
What is the correct syntax as I have tried all sorts code?
|
|
|
|
|
try this:
crReportDocument.SetParameterValue(ParameterName, Value)
|
|
|
|
|
Works a treat now.
A big thank you and have a great weekend.
|
|
|
|
|
Central_IT wrote: Works a treat now.
A big thank you and have a great weekend.
If you are that pleased then at least have the courtesy to give the guy a 5 vote!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have a vb.net application that has to be published on the server to a specified path.
After publishing, when I try to install the application, I get the below error msg:
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of \\agbvseng14\datas\SOFT\Easy_ECN\Nouveau dossier\EASY ECN.application resulted in exception. Following failure messages were detected:
+ Downloading http:
+ Unable to connect to the remote server
+ No connection could be made because the target machine actively refused 180.30.4.18:80
Not sure how to handle this problem.
Any suggestions will be helpful.
Thanks in advance.
modified on Monday, November 29, 2010 7:47 AM
|
|
|
|
|
Your server machine refused the connection for some reason. What's the O/S the server (agbvseng14) is running? Which version of IIS is it running?
|
|
|
|
|
Dave
Is it the server machine that refused the connection or the local machine that has the application refused the connection.
Because, "+ Downloading http://bue479/EASY ECN/EASY ECN.application did not succeed." is my machine, that has the application on it.
Thanks
|
|
|
|
|
Whoops - my bad. I has the right thought though, just typed the wrong name.
|
|
|
|
|
The OS of the server is Windows Server 2003.
|
|
|
|
|
OK, check this page[^].
Is your user sitting behind a proxy that requires authentication?
Try turning off the firewall on the workstation (if present) and see if it installs.
|
|
|
|
|
The below is the appropriate error msg i get:
Application installation did not succeed. Cannot locate applications files on the server. Contact the application publisher or your administrator for assistance.
One or more files in the deployment cannot be downloaded because you do not have permission to access them. This can be caused by a 403 Forbidden error being returned by a Web server, which may occur if one of the files in your deployment ends with an extension that makes the Web server treat it as a protected file. Also, a directory that contains one or more of the application's files might require a username and password in order to access.
Thanks for the link.
|
|
|
|
|
The users gets a dialog box with an error and a Details button. Click the details button and you've get much more information to disagnose the problem.
Your client doesn't have a clear network path to the server or the configuration of the server isn't correct. I don't have enough information to be able to diagnose this over a forum post.
I've already given you a link to the most common problems. It's up to you to do the work and make sure none of those possibilities is the problem.
|
|
|
|
|
hello,
sorry if i'm mispost to this thread, i can't find where to post.
anyway, my problem is i have an access code which will convert to access report to pdf which is ConvertReportToPDF by Lebens code and it is 99% working. 1% problem is, it can't read the unit name such as mg/,μg/c㎡μg/kg,μg/,,㎟/s,,kg/㎡ , etc..
so that is why i need another solution on how to read this kind of fonts when printing to pdf.
help me.
thanks
p.s: i used access 2000
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
It seems that you're not the only one having problems with that library. Why don't you use a different PDF Printer[^] and just print the report to a PDF file?
|
|
|
|
|
thanks for your reply.
problem solved. my boss wants to print access report to pdf automatically but i explain to him that there is a problem on library. so i go to your suggestion that print the report to pdf using pdf printer and its ok for now. i just added code that will set default printer to pdf printer then restore default printer after print to pdf and automatically close pdf file after click save button.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
Hi,
I would like know how I can close a MDI form from a menu while I click on another MDI form.
I have menu with 4 MDI forms. for example A,B, C, D. Load A, it opens, decide to open B, Once B is open, A form should close or any other MDI form that opens, should now be closed.
Any guidance will be very helpfull.
Thanks..
|
|
|
|
|
You'll have to have a collection that your Child forms reside in and contains which forms are open. Frankly, it doesn't sound like you're application is really a candidate for even being an MDI application.
|
|
|
|
|
Hi,
I have an Arm_View(ID, TypeID, Type,Mark, Model) on MDI Form and two comboboxes
TypeCombox binding with Type_viewBindingSource,Display Member(TypeName), Value Member(TypeID),
Selected Value (None)
MarkCombox binding with Mark_viewBindingSource,Display Member(MarkName), Value Member(MarkID),
Selected Value (Type_viewBindingsource-TypeID)
When I click on the TypeCombox for a type, the corresponding Mark shows on the MarkCombox and the Arm_view shows the correct record. But when I try to move away the TypeCombox, the cursor locks, I cannot move away from it.
On Load_event, I load only Arm_view and Type_view and set both of the comboboxes to null..
On TypeCombox_TextChanged, I load Arm_view by Type from the TypeCombox.text
On MarkCombox_TextChanged, I load Arm_view by Mark from the MarkCombox.text
Thanks a lot in advance
|
|
|
|
|
I don't know for this particular case, however in my experience some of the XyzChanged events in .NET also fire when a value gets assigned that is identical to the current value (so their name isn't really accurate!), so it *could* be that your one TextChanged event is firing the other and vice versa, resulting in a never ending loop (or even a stack overflow if you would have a DoEvents in there somewhere).
I suggest you try and break the loop by explicitly checking for a change inside the TextChange event, which probably means you need to add a class variable that holds the previous value. In pseudo-code (which may look a lot like C#) this would be:
class Qwe {
private string oldType;
TypeCombox_TextChanged(...) {
string s=TypeCombox.Text;
if (s != oldType) {
oldType=s;
}
}
You may or may not want to do similar stuff on MarkCombox_TextChanged, in a simple case like this it should not be necessary though.
|
|
|
|
|
Hi,
I am lost from what you suggested but I am suspecting that it has to do with the binding property or column TypeName on the datasource which also causes the form from closing. It throws an exception that cannot bind property or column TypeName on the datasource.
Thanks
|
|
|
|