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.Data.OracleClient;
namespace TestDB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOracle_Click(object sender, EventArgs e)
{
string sql = "select count(*) from tanyixiu.student";
OracleCommand oraComm = new OracleCommand(sql,oracleCon);
try
{
oracleCon.Open();
int number=(int)oraComm.ExecuteScalar(); //改为decimal number=(decimal)oraComm.ExecuteScalar();
string msg=string.Format("Student 表中有{0}条记录!",number);
MessageBox.Show(msg,"查询结果",MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
oracleCon.Close();
}
}
}
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.Data.OracleClient;
namespace TestDB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOracle_Click(object sender, EventArgs e)
{
string sql = "select count(*) from tanyixiu.student";
OracleCommand oraComm = new OracleCommand(sql,oracleCon);
try
{
oracleCon.Open();
int number=(int)oraComm.ExecuteScalar(); //改为decimal number=(decimal)oraComm.ExecuteScalar();
string msg=string.Format("Student 表中有{0}条记录!",number);
MessageBox.Show(msg,"查询结果",MessageBoxButtons.OKCancel,
MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
oracleCon.Close();
}
}
}
}
Oracle中不存在int类型.
记住:所有数值型映射到.NET中,都是decimal !