16,017,261 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ontheline89 (Top 68 by date)
ontheline89
3-Jun-13 13:55pm
View
thank you so much !
ontheline89
3-Jun-13 13:55pm
View
Thank you so much !
ontheline89
13-Mar-13 5:53am
View
Thank you Abhinav !
ontheline89
13-Mar-13 1:18am
View
One thing more i wanted to ask that, above code highlight Entire Row, how can i highlight only specific CELL ?? Thanks
ontheline89
13-Mar-13 0:21am
View
Thank you so much for your reply.
ontheline89
12-Mar-13 4:00am
View
ok thank you. I will check now.
ontheline89
12-Mar-13 3:57am
View
Thank you for your quick reply, I have 4 columns in my Grid.
ontheline89
12-Mar-13 3:51am
View
Still i am getting same error.
ontheline89
28-Feb-13 9:00am
View
thanks .... it was saying, Unused Variable !
ontheline89
27-Feb-13 23:29pm
View
Thank you so much for your answers.
ontheline89
27-Feb-13 5:09am
View
Thank you for your reply.
ontheline89
13-Feb-13 6:44am
View
Actually i am trying to convert Windows app to console app to make a Window service
ontheline89
12-Feb-13 3:27am
View
yes i need datagrid to show me specific results for SensorValue < 20
ontheline89
12-Feb-13 3:16am
View
Datagridview is showing the records in a Database, but i need other datagridview to show the records when the button is pressed for Select Statement.
ontheline89
31-Jan-13 1:05am
View
Thank you so much for your answer.
ontheline89
31-Jan-13 0:49am
View
Thanks for your reply.
I need to use these line in my C# Code ?
ontheline89
31-Jan-13 0:29am
View
Yes i am inserting new rows when i get a value of X variable from COM port.
I need to save X to a new row only when its value change from the previous row value.
ontheline89
31-Jan-13 0:22am
View
i am trying to save values coming from COM Port to a database. when i store these value (X) then many time its value do not change and give same values but after some time its values are changed. I just want to insert the different values in a database.
ontheline89
26-Jan-13 3:40am
View
oh ok thank you !
ontheline89
26-Jan-13 3:13am
View
Jibesh is it the right way to update the data grid view ?
ontheline89
26-Jan-13 2:08am
View
Thank you so much Jibesh.
ontheline89
26-Jan-13 1:01am
View
Thanks for your reply.
You are so helpful thanks again.
ontheline89
26-Jan-13 0:42am
View
Sisir Patro, is there any other way to refresh Datagrid automatically ?
ontheline89
18-Jan-13 1:56am
View
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private Form1 myForm1;
public Form2(Form1 form1)
{
myForm1 = form1;
myForm1.Refreshdatagridview1();
}
}
}
ontheline89
18-Jan-13 1:55am
View
My form 2 is not opening.
The idea which i get from you that, making form 2 and placing a button there, when a user press button it will update datagrid in form 1.
ontheline89
18-Jan-13 1:44am
View
ok thank you so much.
I am trying it now.
ontheline89
18-Jan-13 1:25am
View
Data grid is displaying data from database but how can i automatically update a datagrid as new data goes to database.
ontheline89
18-Jan-13 1:08am
View
Thank you so much.
ontheline89
18-Jan-13 1:03am
View
thank you , i will try to make changes in your web form code.
ontheline89
18-Jan-13 0:59am
View
i need to fetch data and display it in winforms. But i am getting how to display it. Display need to be updated automatically.
ontheline89
17-Jan-13 6:57am
View
i am so sorry i have taken so much time of yours.
Yes i have put these lines in my code in Visual Studio, actually these lines were not copied here.
Thank you so v much for your time and guidance.
ontheline89
17-Jan-13 6:48am
View
what i need to change in it now ?
ontheline89
17-Jan-13 6:44am
View
seriously i didnt get your point.
ontheline89
17-Jan-13 6:39am
View
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.Media;
using System.Data.SqlClient;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
serialPort1.Open();
}
public void playSimpleSound()
{
SoundPlayer simpleSound = new SoundPlayer(@"c:\smokealarm.wav");
simpleSound.Play();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'latestsensordataDataSet1.Table_1' table. You can move, or remove it, as needed.
this.table_1TableAdapter1.Fill(this.latestsensordataDataSet1.Table_1);
// TODO: This line of code loads data into the 'latestsensordataDataSet.Table_1' table. You can move, or remove it, as needed.
this.table_1TableAdapter.Fill(this.latestsensordataDataSet.Table_1);
//configuring the serial port
serialPort1.PortName = "COM14";
serialPort1.BaudRate = 115200;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
}
public enum MessageType { Incoming, Outgoing, Normal, Warning, Error };
private byte[] HexToByte(string msg)
{
//remove any spaces from the string
msg = msg.Replace(" ", "");
//create a byte array the length of the
//divided by 2 (Hex is 2 characters in length)
byte[] comBuffer = new byte[msg.Length / 2];
//loop through the length of the provided string
for (int i = 0; i < msg.Length; i += 2)
//convert each set of 2 characters to a byte
//and add to the array
comBuffer[i / 2] = (byte)Convert.ToByte(msg.Substring(i, 2), 16);
//return the array
byte[] newbuffer = comBuffer;
return comBuffer;
}
private string ByteToHex(byte[] comByte)
{
//create a new StringBuilder object
StringBuilder builder = new StringBuilder(comByte.Length * 3);
//loop through each byte in the array
foreach (byte data in comByte)
//convert the byte to a string and add to the stringbuilder
builder.Append(Convert.ToString(data, 16).PadLeft(2, '0').PadRight(3, ' '));
//return the converted value
return builder.ToString().ToUpper();
}
#region DisplayData
private void DisplayData(MessageType type, string msg)
{
richTextBox1.Invoke(new EventHandler(delegate
{
string substring = string.Empty;
if (msg.Length > 57)
substring = msg.Substring(54, 2);
int x;
bool f = Int32.TryParse(substring, System.Globalization.NumberStyles.HexNumber, null, out x);
if (f)
{
string hexValue = x.ToString();
richTextBox1.AppendText(hexValue);
try
{
SqlConnection sqlconn = new SqlConnection("Data Source=ARSALAN-PC;Initial Catalog=latestsensordata;Integrated Security=True");
SqlDataAdapter sa = new SqlDataAdapter();
string query = "insert into Table_1(SensorValue,Time) values(@SV, @TM)";
sa.InsertCommand = new SqlCommand(query, sqlconn);
ontheline89
17-Jan-13 6:36am
View
you are absolutely right, i dont have expertise in databases and c# thats why i am confused why i am not getting time with values.
ontheline89
17-Jan-13 6:33am
View
#region DisplayData
private void DisplayData(MessageType type, string msg)
{
richTextBox1.Invoke(new EventHandler(delegate
{
string substring = string.Empty;
if (msg.Length > 57)
substring = msg.Substring(54, 2);
int x;
bool f = Int32.TryParse(substring, System.Globalization.NumberStyles.HexNumber, null, out x);
if (f)
{
string hexValue = x.ToString();
richTextBox1.AppendText(hexValue);
try
{
SqlConnection sqlconn = new SqlConnection("Data Source=ARSALAN-PC;Initial Catalog=latestsensordata;Integrated Security=True");
SqlDataAdapter sa = new SqlDataAdapter();
string query = "insert into Table_1(SensorValue) values(" +hexValue+")";
sa.InsertCommand = new SqlCommand(query, sqlconn);
sqlconn.Open();
try
{
sa.InsertCommand.ExecuteNonQuery();
}
catch (FormatException ex) { MessageBox.Show(ex.Message); }
MessageBox.Show("Record Inserted");
sqlconn.Close();
}
catch (SqlException ea) { MessageBox.Show(ea.Message); }
}
ontheline89
17-Jan-13 6:30am
View
If i use
string query = "insert into Table_1(SensorValue) values(" +hexValue+")";
Then sensor value is stored in database.
ontheline89
17-Jan-13 6:24am
View
I have two columns in SQL Server
SensorValue ( int )
Time (nchar)
ontheline89
17-Jan-13 6:21am
View
but it still giving the same error.
Must declare the Scalar Variable at @SV.
ontheline89
17-Jan-13 6:01am
View
I am still getting error
Must declare the Scalar Variable at @SV
ontheline89
17-Jan-13 5:23am
View
I am getting error,
Invalid column name CurrntTime.
ontheline89
17-Jan-13 5:08am
View
I am getting error in above your statement.
Invalid Expresstion ","
ontheline89
17-Jan-13 3:42am
View
I am getting some values which are in not in correct format. But how to avoid them ?
ontheline89
17-Jan-13 3:39am
View
yes the format of values changer after some time, you can say some garbage values. Is there any way that it just convert only strings which are in format and discard other without getting any errors.
ontheline89
17-Jan-13 2:56am
View
i am getting correct values, but after 4 to 5 values, i get error that
Input Sting was not in a correct format.
ontheline89
17-Jan-13 2:44am
View
I cant avoid values like 1A OR 1B.
These are HEXADECIMAL values and i need to convert them to integers.
I am still getting errors.
ontheline89
17-Jan-13 1:14am
View
Thank you so much !
ontheline89
17-Jan-13 1:08am
View
Thank you so much Sisri Patro.
It worked.
ontheline89
17-Jan-13 0:54am
View
Thank you for your reply but i am still getting error.
Must Declare the Scalar Variable "@SensorValue"
ontheline89
17-Jan-13 0:39am
View
Thank you for your reply,
ontheline89
16-Jan-13 8:58am
View
Hello Jibesh,
If i need to store these substring to a SQL Server Database with TimeStamp then what should i do? Thanks
ontheline89
16-Jan-13 0:14am
View
I have just seen your reply. Thank you so much !
ontheline89
1-Jan-13 9:29am
View
Jibesh can you please tell one thing more, i am trying to play a .wav file when sub string value is 1B , but i am getting Int to string conversion errors .....private void DisplayData(MessageType type, string msg)
{
richTextBox1.Invoke(new EventHandler(delegate
{
string substring = string.Empty;
if (msg.Length > 57)
substring = msg.Substring(54, 3);
if (substring = 1B)
playSimpleSound();
richTextBox1.AppendText(substring) ;
richTextBox1.SelectedText = string.Empty;
richTextBox1.ScrollToCaret();
}));
}
#endregion
public void playSimpleSound()
{
SoundPlayer simpleSound = new SoundPlayer(@"c:\smokealarm.wav");
simpleSound.Play();
}
ontheline89
31-Dec-12 3:28am
View
i tried it ,
int decValue = Convert.ToInt32(hexValue, 16);
not working
ontheline89
31-Dec-12 3:18am
View
thanks .... Jibesh you helped me a lot ,
one more thing i need to ask from you.
I am getting values which are in Hexadecimal , i need to convert Sub Sting in Decimal. what should i do ?
ontheline89
31-Dec-12 3:08am
View
Thanks you Jibesh its working now correctly. I did this as you said.
if (msg.Length > 57)
substring = msg.Substring(54, 3);
ontheline89
31-Dec-12 3:03am
View
Jibesh i did this. But it still gives error after displaying some values correctly.
Index and length must refer to a location within the string. ERROR
ontheline89
31-Dec-12 3:00am
View
The length of a string is varying.
It gives error " Index and length must refer to a location within the string. "
ontheline89
31-Dec-12 2:56am
View
i have checked it, string length is changing.
Most of time it gives about 57 value long string, but after some time, its length reduces.
ontheline89
31-Dec-12 2:53am
View
7E 45 00 FF FF 00 01 0A 00 93 00 00 01 00 00 01 00 13 18 75 51 9D 7E
This is a string.
But number of values in strings are changing with time.
How can i set indexes of a string when its indexes are changing with time.
ontheline89
31-Dec-12 2:02am
View
Jibesh just one thing more,
Why you have used values 54 and 4 in your solution ?
ontheline89
31-Dec-12 1:56am
View
thanks
good day to you too.
ontheline89
31-Dec-12 1:53am
View
ok thank you so much for your solution.
I am trying your solution now.
Thanks once again.
ontheline89
31-Dec-12 1:45am
View
I just need to display values at Index 19 and 20. Whatever the values are at index 19 and 20.
ontheline89
31-Dec-12 1:43am
View
I dont need that combination. i just need to display elements at index 19 and 20 as values are changing in every minute at serial port.
ontheline89
31-Dec-12 1:41am
View
yes i want to display values at given indexes 19 and 20.
I dont know, where i need to change my code for it.
ontheline89
31-Dec-12 1:38am
View
Right now i am getting this large output
7E 45 00 FF FF 00 01 0A 00 93 00 00 01 00 00 01 00 02 17 B5 70 20 7E
I just need to extract 17 and B5 from above output.
ontheline89
31-Dec-12 1:31am
View
I dont know, what need to be change in above code to display that specific elements.
Show More