我正在尝试对会计系统进行编码,我应该在其中输入产品ID,产品名称和产品价格。之后,应将其存储在.accdb文件中
我的问题是,当我在产品ID中输入10位数以上时,datagridview给我一个错误,指出该值对于int32类型而言太大。
错误:
其他信息:对于一个广告而言,值太大或太小 Int32。无法将<6221060003181>存储在Item_Code列中。预期 类型是Int32。
当我打开accdb文件时,我发现存储了数据;但是下次我打开表格时,它给了我这个错误!
public partial class Productentry : MetroFramework.Forms.MetroForm
{
public OleDbConnection connection = new OleDbConnection();
public Productentry()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Sama_Software\WindowsFormsApplication1\WindowsFormsApplication1\DB.accdb;Jet OLEDB:Database Password=**************";
}
private void Productentry_Load(object sender, EventArgs e)
{
ViewData();
// TODO: This line of code loads data into the 'dBDataSet.Product' table. You can move, or remove it, as needed.
this.productTableAdapter1.Fill(this.dBDataSet.Product);
ViewData();
}
void ViewData()
{
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Product]",connection);
da.Fill(this.dBDataSet.Product);
}
private void bunifuButton4_Click(object sender, EventArgs e)
{
this.Close();
}
private void bunifuButton3_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("INSERT INTO [Product] (Item_Code, Item_Name, Price) VALUES ('" + Pidn.Text + "','" + name.Text + "','" + price.Text + "')", connection);
da.Fill(dBDataSet)
ViewData();
Pidn.Clear();
name.Clear();
price.Clear();
}
private void Cat_TextChange(object sender, EventArgs e)
{
}
private void bunifuButton1_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("UPDATE [Product] WHERE [Item_Code]=" + Pidn.Text + " SET [Item_Name]='" + name.Text + "',[Price]=" + price.Text + "", connection);
da.Fill(dBDataSet);
ViewData();
Pidn.Clear();
name.Clear();
price.Clear();
}
private void bunifuButton4_Click_1(object sender, EventArgs e)
{
this.Close();
}
private void Pid_TextChange(object sender, EventArgs e)
{
}
}
}
答案 0 :(得分:0)
将条形码存储为文本。
即使它是由数字构成的,它也不是数字,而是固定长度的代码,甚至可能有前导零。