|
+1 for Compuserve , before that I had a huge collection of expensive and outdated books.
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
hi
i have this C# code for reading port via rs232
port = new SerialPort(MyParam._COM, Brate, Parity.None, 8, StopBits.One);
port.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(Recepcion);
private SerialPort port;
string Recibidos;
private void Recepcion(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
try
{
Recibidos = "";
Application.DoEvents();
System.Threading.Thread.Sleep(122);
Recibidos += port.ReadExisting();
this.Invoke(new EventHandler(Actualizar));
}
catch { }
string text;
decimal dTEXT;
private void Actualizar(object s, EventArgs e)
{
text = Recibidos.Trim();
lblMSG.Text = text;
}
I have a weight attached to rs232 and i get Strange reading.
for example - if the weight show 14.23 Kg
i see:
14.23 Kg
0
14.
14.2
14.23
14.23 Kg
How to show the exact weight without breaking the string ?
|
|
|
|
|
Maybe don't use port.ReadExisting() ?
Also, try using a StringBuilder rather than a string.
|
|
|
|
|
It seems you need to call port.DiscardInBuffer() after each call to ReadExisting() .
/ravi
|
|
|
|
|
thanks for the help, i'll try this and I'll update the findings.
|
|
|
|
|
Using Silverlight and c#:
I have a datagrid having PropertyGroupDescription added to it and also have Item templates in it.. If I edit a row which is exist in the middle of the grid..after saving that data by using that save button in the panel...what happened is the data grid rebinding and the pointer goes to the first record in the datagrid. I want the scroll to maintain its position to the row which is edited after its ItemSource is changed. I tried using ScrollIntoView as follows:
tblSessionDataGrid.Focus();
tblSessionDataGrid.SelectedItem = objSelectedItem;
tblSessionDataGrid.CurrentColumn = tblSessionDataGrid.Columns[0];
tblSessionDataGrid.ScrollIntoView(objSelectedItem, tblSessionDataGrid.Columns[0]);
But its now working. Can anyone please suggest where I am going wrong?
|
|
|
|
|
hi
looking for C# sample code reading weight Through rs232 - WinForm
I found some on the net - but none worked,
Even after I pointed all settings (com....BaudRate....)
thanks
|
|
|
|
|
We probably can't help: you are going to have to talk to the manufacturers of the specific make and model of weighing machine you are connecting. There is no one standard method of communicating, so you need to get hold of an manual, or better a person who knows what is provided.
Anything else is just guesswork!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Most scale serial protocols are very simple. Typically you send a single character ('W' or 'P' are common) and get a 'CR' or 'CR' 'LF' terminated string in response.
HyperTerminal is a decent way to debug serial communication(to ensure you have the parameters right). You can copy two files from any XP machine to get it back. The files you need are hypertrm.dll and hypertrm.exe.
A pretty highly regarded alternative to HyperTerminal is Putty. You can learn more about Putty here.
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html[^]
I used to design scales in my previous job, and am familiar with scale RS232 and USB communication. Post the manufacturer and model number of the scale you are trying to talk to and I might be able to give more direct help.
Another thing to keep in mind is that most scales have configurable protocols so you will need to verify how the scale is configured when writing your software. You are going to need the scale's tech manual to be able to do this.
|
|
|
|
|
Hi all.
when I get the value of ifInObtets with oid = 1.3.6.1.2.1.2.2.1.10, it's not return values.
modified 7-Aug-15 5:16am.
|
|
|
|
|
What are you talking about?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Locating source for 'g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs'. Checksum: MD5 {fd 8f f6 ab 44 c1 61 7f ce 22 49 1 16 fd 1b a3}
Determining whether the checksum matches for the following locations:
1: G:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs Checksum: MD5 {8a 98 38 8f 62 55 ff 74 fb 78 c1 f0 c6 8d 6b 5f} Checksum doesn't match.
The file 'g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs' exists.
Looking in script documents for 'g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs'...
Determining whether the checksum matches for the following locations:
1: g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs Checksum: MD5 {8a 98 38 8f 62 55 ff 74 fb 78 c1 f0 c6 8d 6b 5f} Checksum doesn't match.
Looking in the projects for 'g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs.
The debugger could not locate the source file 'g:\Office Projects\BD-Projects-Live\School-V3\School.Web\Admin\FeesNew\ManageFeeSetup.aspx.cs'.
|
|
|
|
|
You seem to be missing a question. All you have shown here is that you have the ability to copy and paste (oh, and you've also shown some of your project directory structure which is never a good thing).
|
|
|
|
|
|
Hello everyone.
I'm beginner with open source SNMP class library(#SNMP Library).
I want to calculate Bandwidth Utilization based on ifInObtets and ifOutOctets. How can I do? How can I get values fInObtets and ifOutOctets.
I need help. Hope someone can help me.
|
|
|
|
|
|
|
this is the code for login button that should check the database and then show another form.but instead its always giving me the else part here, what am i doing wrong here.
{
SqlConnection con = new SqlConnection(@"Data Source=SAJJAD-PC;Initial Catalog=hotel;Integrated Security=True;");
SqlDataAdapter sda = new SqlDataAdapter("select count(*) from login where username = '" + usernametxtbox+"'and password = '" +passwordtxtbox+"'",con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
con.Open();
this.Hide();
Form5 form5 = new Form5();
form5.Show();
}
else
{
MessageBox.Show("Please Check your username and password again !");
}
|
|
|
|
|
Hi
Can you please try like this
if (dt.Rows.count > 0)
{
con.Open();
this.Hide();
Form5 form5 = new Form5();
form5.Show(); }
|
|
|
|
|
Dark Commet wrote: what am i doing wrong here.
Would you like a list?
Being honest, the answer is "pretty much everything".
You break the two first rules of databases:
1) Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
2) Never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]
Then, you don't check to see if there are any values in your data:
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
Then you unnecessarily convert to string, and do string comparisons,you use default names for forms, you don't dispose of objects that hold scarce resources, you don't do any error checking, you...
You get the idea. You have a long way to go.
So follow the link, have a read of the code there, and then change your db to support hashed passwords.
Return the hashed password for the user name, and compare that instead of trying to get the count. And please - for your own sake - use parameterised queries at all times!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
First: Don't use string concatenation to build your SQL queries!
A few more issues:
- "usernametxtbox" and "passwordtxtbox probably results in something like "System.Windows.Forms.TextBox" instead of the actual value. Make sure you access the "Text" property of those objects to get the value stored inside them
- There is no need for a DataTable or an SqlDataAdapter.
- Make sure you dispose of the Sql-objects if you're done (else you might run into memory leaks)
Go with something like this (using "using" will make sure the objects are disposed)
using(var con = new SqlConnection(@"Data Source=SAJJAD-PC;Initial Catalog=hotel;Integrated Security=True;") {
con.Open();
using(var cmd = con.CreateCommand()) {
cmd.CommandText="SELECT COUNT(*) FROM login WHERE username=@username AND password=@password";
cmd.Parameters.Add("@username", SqlDbType.Varchar, 50).Value = usernametxtbox.Text;
cmd.Parameters.Add("@password", SqlDbType.Varchar, 50).Value = passwordtxtbox.Text;
var result = (int)cmd.ExecuteScalar();
if(result==1) {
} else {
}
}
}
|
|
|
|
|
I think usernametxtbox and passwordtxtbox are your text box controls. use usernametxtbox.Text.ToString().Trim() and passwordtxtbox.Text.ToString().Trim().
and if you have more then one record with same username and password then row count will be grater than 1 and in this condition
login will be failed. so you need to check what table return form database.
|
|
|
|
|
HUKUMAT RAY KUMAWAT wrote: usernametxtbox.Text.ToString() Why do you want to call ToString() on a property that is already a string?
|
|
|
|
|
I should refresh my page more often
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|