Click here to Skip to main content
14,935,580 members
Home / Discussions / Database
   

Database

 
AnswerRe: Disallowed implicit conversion from data type smalldatetime to data type float Pin
Victor Nijegorodov18-Mar-21 21:15
MemberVictor Nijegorodov18-Mar-21 21:15 
GeneralRe: Disallowed implicit conversion from data type smalldatetime to data type float Pin
jkirkerx19-Mar-21 6:58
professionaljkirkerx19-Mar-21 6:58 
GeneralRe: Disallowed implicit conversion from data type smalldatetime to data type float Pin
jsc4219-Mar-21 7:45
professionaljsc4219-Mar-21 7:45 
GeneralRe: Disallowed implicit conversion from data type smalldatetime to data type float Pin
jkirkerx19-Mar-21 8:54
professionaljkirkerx19-Mar-21 8:54 
GeneralRe: Disallowed implicit conversion from data type smalldatetime to data type float Pin
jsc4219-Mar-21 11:17
professionaljsc4219-Mar-21 11:17 
GeneralKearning Python Pin
Lumbeta Aquirok17-Mar-21 23:50
MemberLumbeta Aquirok17-Mar-21 23:50 
GeneralRe: Kearning Python Pin
Richard MacCutchan18-Mar-21 0:01
mveRichard MacCutchan18-Mar-21 0:01 
QuestionSystem.NullReferenceException: Pin
H. Martins23-Feb-21 14:28
MemberH. Martins23-Feb-21 14:28 
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)
        {
            // Line, Abs, Rel, X, C_t, C_i, C_n, MinSpeed, MaxSpeed, Accel, Decel
            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 Smile | :) where everything seems to run smoothly.

Any help would be greatly appreciated.
Thanks
Martins

modified 23-Feb-21 21:02pm.

AnswerRe: System.NullReferenceException: Pin
Richard MacCutchan23-Feb-21 22:04
mveRichard MacCutchan23-Feb-21 22:04 
GeneralRe: System.NullReferenceException: Pin
Richard Deeming23-Feb-21 22:19
mveRichard Deeming23-Feb-21 22:19 
GeneralRe: System.NullReferenceException: Pin
Richard MacCutchan23-Feb-21 22:31
mveRichard MacCutchan23-Feb-21 22:31 
QuestionGeneral advice about simple table storage. Pin
H. Martins19-Feb-21 9:34
MemberH. Martins19-Feb-21 9:34 
AnswerRe: General advice about simple table storage. Pin
Eddy Vluggen20-Feb-21 7:04
professionalEddy Vluggen20-Feb-21 7:04 
GeneralRe: General advice about simple table storage. Pin
H. Martins21-Feb-21 3:26
MemberH. Martins21-Feb-21 3:26 
GeneralRe: General advice about simple table storage. Pin
NotTodayYo12-Mar-21 7:17
MemberNotTodayYo12-Mar-21 7:17 
GeneralRe: General advice about simple table storage. Pin
Eddy Vluggen13-Mar-21 6:09
professionalEddy Vluggen13-Mar-21 6:09 
AnswerMessage Closed Pin
28-Feb-21 7:51
MemberMember 1508622528-Feb-21 7:51 
QuestionWITSML Server And Client in C# Pin
Member 1332584614-Feb-21 21:54
MemberMember 1332584614-Feb-21 21:54 
AnswerRe: WITSML Server And Client in C# Pin
Richard MacCutchan14-Feb-21 22:21
mveRichard MacCutchan14-Feb-21 22:21 
GeneralRe: WITSML Server And Client in C# Pin
Member 1332584614-Feb-21 22:53
MemberMember 1332584614-Feb-21 22:53 
Generalneed website to create database Pin
Member 150643285-Feb-21 12:51
MemberMember 150643285-Feb-21 12:51 
QuestionRe: need website to create database Pin
Eddy Vluggen5-Feb-21 13:09
professionalEddy Vluggen5-Feb-21 13:09 
GeneralRe: need website to create database Pin
RickZeeland5-Feb-21 20:19
mveRickZeeland5-Feb-21 20:19 
AnswerRe: need website to create database Pin
Slacker0076-Feb-21 2:33
professionalSlacker0076-Feb-21 2:33 
GeneralRe: need website to create database Pin
dandy726-Feb-21 3:16
Memberdandy726-Feb-21 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.