c# vs2008 报错未将对象引用设置到对象的实例
record.cs
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace WindowsFormstest
{
class record
{
private int SN;
private int TASK;
private float MOVE;
private float TURN;
private float[] TEMP;
private float QUAKE;
public int sn
{
get { return SN;}
set { SN = value; }
}
public int task
{
get { return TASK;}
set { TASK = value; }
}
public float move
{
get { return MOVE; }
set { MOVE = value; }
}
public float turn
{
get { return TURN; }
set { TURN = value; }
}
public float[] temp{get;set;}
public float quake
{
get { return QUAKE; }
set { QUAKE = value; }
}
}
}
recordDAL.cs
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace WindowsFormstest
{
class recordDAL
{
private const string sconn="F:/Grade 1 master/study/WindowsFormstest/WindowsFormstest/data/20130512230545.db;Version=3;";
//查询温度记录
public static record Gettemp()
{
try
{
using (SQLiteConnection conn = new SQLiteConnection(sconn))
{
conn.Open();
SQLiteCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT temp FROM record_run ;";
//cmd.Parameters.Add(new SQLiteParameter("task", task));
SQLiteDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
record RECORD = new record();
int i=0;
do
{
i++;
RECORD.temp[i] = dr.GetFloat(i);
}
while (dr.GetFloat(i)!= 0);
return RECORD;
}
else
return null;
}
}
catch (Exception)
{
//Do any logging operation here if necessary
return null;
}
}
}
}
主界面:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormstest
{
public partial class chart : Form
{
public chart()
{
InitializeComponent();
}
//private const string sConn = "F:/Grade 1 master/study/WindowsFormstest/WindowsFormstest/data/20130512230545.db;Version=3;";
private void btntemp_Click(object sender, EventArgs e)
{
//显示温度
record RECORD = new record();
RECORD = recordDAL.Gettemp();
Console.WriteLine(RECORD.temp[0]);
}
}
}
程序报错:未将对象引用设置到对象的实例
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace WindowsFormstest
{
class record
{
private int SN;
private int TASK;
private float MOVE;
private float TURN;
private float[] TEMP;
private float QUAKE;
public int sn
{
get { return SN;}
set { SN = value; }
}
public int task
{
get { return TASK;}
set { TASK = value; }
}
public float move
{
get { return MOVE; }
set { MOVE = value; }
}
public float turn
{
get { return TURN; }
set { TURN = value; }
}
public float[] temp{get;set;}
public float quake
{
get { return QUAKE; }
set { QUAKE = value; }
}
}
}
recordDAL.cs
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace WindowsFormstest
{
class recordDAL
{
private const string sconn="F:/Grade 1 master/study/WindowsFormstest/WindowsFormstest/data/20130512230545.db;Version=3;";
//查询温度记录
public static record Gettemp()
{
try
{
using (SQLiteConnection conn = new SQLiteConnection(sconn))
{
conn.Open();
SQLiteCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT temp FROM record_run ;";
//cmd.Parameters.Add(new SQLiteParameter("task", task));
SQLiteDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
record RECORD = new record();
int i=0;
do
{
i++;
RECORD.temp[i] = dr.GetFloat(i);
}
while (dr.GetFloat(i)!= 0);
return RECORD;
}
else
return null;
}
}
catch (Exception)
{
//Do any logging operation here if necessary
return null;
}
}
}
}
主界面:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormstest
{
public partial class chart : Form
{
public chart()
{
InitializeComponent();
}
//private const string sConn = "F:/Grade 1 master/study/WindowsFormstest/WindowsFormstest/data/20130512230545.db;Version=3;";
private void btntemp_Click(object sender, EventArgs e)
{
//显示温度
record RECORD = new record();
RECORD = recordDAL.Gettemp();
Console.WriteLine(RECORD.temp[0]);
}
}
}
程序报错:未将对象引用设置到对象的实例
...全文
相关推荐
C#汉王人脸识别系统源码VS2008
**C#编程语言**:C#是一种由微软开发的面向对象的编程语言,主要用于.NET框架。
VS2008 卸载工具
**二、VS2008卸载问题**在常规的Windows控制面板中卸载VS2008时,可能由于注册表残留、组件未完全卸载等原因导致卸载不彻底,进而影响新版本的安装。
vs2008和matlab混合编程
- 如果以上设置完成后,运行仍然报错,可以尝试关闭VS2008后再重新启动。有时环境变量设置好后,仍然会出现报错的情况,这时可以尝试重启计算机或关闭当前工程,再次启动运行。**4.
VS2008无法直接查看STL值的解决方法
"VS2008无法直接查看STL值的解决方法"在使用Visual Studio 2008 (VS2008)进行软件开发时,有时会遇到在调试过程中无法直观地查看STL(Standard Templa
Halcon导出至C#基于VS2010
如果程序崩溃或报错,需要检查图像路径是否正确,确保Halcon软件安装无误,环境变量设置正确。


