|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Hi. (I am Portuguese)
********UPDATE*******
Looks like I found the problem
In the first for() there was a 1 instead of an i.
I realized that after increasing zoom level.
I apologize.
**************
I am a new-by to Visual Studio and C# classes and I am trying to extract a GridView content to a CSV format file.
Handling and processing fields seems not too difficult but the extraction is fighting me.
I run the compiler, the form shows up, I fill the grid clicking the fill button, it fills OK but when I press the button to export, I get:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Windows.Forms.DataGridViewCell.Value.get returned null.
In both similar lines:
writer.Write(dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
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;
namespace Stepping
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void btnSave01_MouseClick(object sender, MouseEventArgs e)
{
TextWriter writer = new StreamWriter(@"H:\proj\_Programacao\_Arduino\ArduinoHM\Stepper_Polling_us\WinApp\M01.txt");
for (int i = 0; 1 < dataGridViewMotor1.Rows.Count - 1; i++)
{
for (int j = 0; j < dataGridViewMotor1.Columns.Count; j++)
{
if (j == 0)
{
writer.Write(dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
}
else
{
writer.Write("," + dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
}
}
}
writer.Close();
MessageBox.Show("Data Exported");
}
private void btnFillTestData_MouseClick(object sender, MouseEventArgs e)
{
dataGridViewMotor1.Rows.Add(1,0, 120,0,0,0,0, 10, 100, 0.9, 0.9 );
dataGridViewMotor1.Rows.Add(2,0,120, 0, 0, 0, 0, 10, 100, 0.9, 0.9);
dataGridViewMotor1.Rows.Add(3,0, 80, 0, 0, 0, 0, 10, 100, 0.9, 0.9);
}
}
}
Some fields were empty "" I thought that could be the problem, I filled them all still the problem remains.
I got this code from a video where everything seems to run smoothly.
Any help would be greatly appreciated.
Thanks
Martins
modified 23-Feb-21 21:02pm.
|
|
|
|
|
for (int i = 0; 1 < dataGridViewMotor1.Rows.Count - 1; i++)
Your compare expression is still wrong. The expression 1 < dataGridViewMotor1.Rows.Count - 1 will always be true. It should be i < dataGridViewMotor1.Rows.Count .
And a suggestion: don't rely on videos to teach you how to program. Get a good online tutorial, or book, and learn the actual language first. Using Windows forms and complex controls without understanding the structure of the language properly is a waste of your time.
|
|
|
|
|
Unless the Rows collection contains a blank insertion row at the end, in which case i < dgv.Rows.Count - 1 would be correct.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Quite right. But any program worth its salt would be validating the content as it goes through them. And if there is not a blank row at the end then a complete line of data will be missed.
|
|
|
|
|
I need some general advice. (My natural language is Portuguese).
I need to do a small Windows desktop application to fill (by hand) a single table with, say, a maximum of one thousand records of some 20 fields for later manipulation.
About 15 years ago I have done a database application in Access 2003 whose tables were separately stored (same folder) without a SQL server. I would like to stay away from Access and use Visual Studio Community and, also, stay away from a SQL server or the need to have it installed in the computers where the application will run.
I suppose that to crate a table in a form must not be complicated (I have already played a little bit with that) but I am at a lost about storing the table on disk without SQL database/server. All examples I found in the Web involve SQL servers.
Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable because importing some data from excel could eventually be interesting. The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application.
At the moment I am flying around without a place to land. Any help would be greatly appreciated.
H. Martins
|
|
|
|
|
Member 15078113 wrote: suppose that to crate a table in a form must not be complicated It's not; I'd recommend SQLite, if you familiar with databases. It's free and small. Also comes without UI, but you can download those separate.
Member 15078113 wrote: Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable Then EPPlus or LinqToExcel might be more suitable.
Member 15078113 wrote: The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application. That's your fourth option; CSV files. A few thousand records would hardly be a speed-problem on modern machines (anything that can run .NET).
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thank you very much.
I have been fighting Visual Studio for a couple hours and managed to create the basic GridView configuration. Although in the much simpler Arduino environment, I am familiarized with C and I have recently written a couple Classes ( I should have started before ). Nevertheless helped by some web browsing I suppose I can handle the code behind the forms.
I decided to leave Excel for later and concentrate in creating and reading CVS files.
Then EPPlus or LinqToExcel might be more suitable.
Thank you again.
|
|
|
|
|
|
I want to make a server and client side WITSML (for Oil & Gas Wells Drilling Data Send/Receive). There are some SDKs here: (WITSML api library for .Net / C# client apps?). I surfed though the internet, but i have not been found any code example or guide to use them.
My Question:
==>.Are There any code example to develop a WITSML and/or WITS server and Client side software in C#?
Thank you in advance.
|
|
|
|
|
You already posted this question in the C# forum. Please do not crosspost. You need to go and study those SDKs and the WITSML specification language.
|
|
|
|
|
Sorry, Duplication was a mistake. Thank you for your note.
|
|
|
|
|
Hey, I know that this is a dumb question but I did this in the past and I can't find the tool now. Basically I want to combine words list so:
1st column word + 2nd column word + 3rd column word
and get all possible combinations.
Sorry if I'm not explaining it nicely.
Thanks!!!
modified 5-Feb-21 19:39pm.
|
|
|
|
|
You don't need a website for a database.
Member 15064328 wrote: 1st column word + 2nd column word + 3rd column word
and get all possible combinations. That'd take a lot of CPU time. Care to explain why?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|
Member 15064328 wrote: Sorry if I'm not explaining it nicely.
Yeah, next time tell your teacher to do a better job explaining your assignments.
[Edit]
How the heck did I end up here in the 'Databases' section?
[Edit]
Never mind. I see the original message from the lounge has been moved. I read CP through an RSS reader, and the link just forwarded me there instead of staying in the lounge.
|
|
|
|
|
|
|
|
Hi Sir,
I try to query record from Firebird where to get record today only with this statement :
<pre>SELECT * FROM EVENT WHERE EVENTDATE >= CAST('NOW' AS DATE) AND EVENTMSG ='Access Granted'
ORDER BY EVENTDATE
Unfortunately the record appear today record and beyond ( next day upward). Can anyone help me to get record by today only.
Tq in advance.
|
|
|
|
|
WHERE EVENTDATE >= CAST('NOW' AS DATE)
Your WHERE clause tells it to select records where the date is greater than or equal to today. Change it to equal only.
|
|
|
|
|
Sir,
I'm already change the statement to equal '=' but nothing record display,plz help me tq
|
|
|
|
|
Be aware that if your date is stored as a datetime (almost certainly is) you are going to have to get a range for the day + time.
The => you are using is a kludge to get that range.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|