oleDbDataAdapter1.Update(dataSet21.Tables[0]);
添加记录到数据集之后,添加的记录没真正存入数据库中,
是不是2005的与2003的有什么不同啊,请指教,
还有一个很简单的问题:对话框的关键字是什么?好久没用了,都忘得差不多了
请各位多多帮助,在此谢过了!
添加记录到数据集之后,添加的记录没真正存入数据库中,
是不是2005的与2003的有什么不同啊,请指教,
还有一个很简单的问题:对话框的关键字是什么?好久没用了,都忘得差不多了
请各位多多帮助,在此谢过了!
2。MessageBox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace yach
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
oleDbDataAdapter1.Fill(dataSet21);
oleDbDataAdapter2.Fill(dsClass1);
oleDbDataAdapter3.Fill(dsClass1);
}
private void button2_Click(object sender, EventArgs e)
{
Close();
} private void button1_Click(object sender, EventArgs e)
{
//string str;
//str = "select product ya1";
//System.Data.OleDb.OleDbDataAdapter da=new System.Data.OleDb.OleDbDataAdapter(str,oleDbConnection1); }
//计算结存数量
private void num()
{
} private void button3_Click(object sender, EventArgs e)
{
dialog1 dlg = new dialog1();
dlg.ShowDialog();
//System.Windows.Forms.CommonDialog cd = new System.Windows.Forms.CommonDialog();
} private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox1 ab = new AboutBox1();
ab.ShowDialog();
} private void button4_Click(object sender, EventArgs e)
{
diglog2 dlg2 = new diglog2();
dlg2.ShowDialog();
} private void button5_Click(object sender, EventArgs e)
{
oleDbDataAdapter1.Update(dataSet21.Tables[0]);
} private void button2_Click_1(object sender, EventArgs e)
{
Close();
} private void button5_Click_1(object sender, EventArgs e)
{
oleDbDataAdapter1.Update(dataSet21.Tables[0].GetChanges());
} private void oleDbDataAdapter1_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
{ } private void 管理员ToolStripMenuItem_Click(object sender, EventArgs e)
{
user us = new user();
us.ShowDialog();
} private void 浏览数据ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.ShowDialog();
} private void 查询数据ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form5 f5 = new Form5();
f5.ShowDialog();
} private void 退出系统ToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
} private void button1_Click_1(object sender, EventArgs e)
{
DataSet2.ya1Row rw = dataSet21.ya1.Newya1Row();
rw.title = textBox1.Text;
rw.address = textBox2.Text;
rw.max = System.Int32.Parse(textBox3.Text);
rw.min = System.Int32.Parse(textBox4.Text);
rw.unit = comboBox1.Text;
rw.spec = textBox5.Text;
rw.num = System.Int32.Parse(textBox6.Text);
rw._class = comboBox2.Text;
rw.date = dateTimePicker1.Value;
rw.sort = textBox7.Text;
rw.number = System.Int32.Parse(textBox8.Text);
rw.product = comboBox3.Text;
if (System.Int32.Parse(textBox9.Text) > 0)
{
rw.inCome = System.Int32.Parse(textBox9.Text);
}
else
{
rw.inCome=0;
}
if (System.Int32.Parse(textBox10.Text) > 0)
{
rw.sendOut = System.Int32.Parse(textBox10.Text);
}
else
{
rw.sendOut = 0;
}
dataSet21.ya1.Rows.Add(rw); oleDbDataAdapter1.Update(dataSet21);
oleDbDataAdapter1.Fill(dataSet21);
} }
}
旧问题没解决新问题又来了,烦死了
rw.max = System.Int32.Parse(textBox3.Text);这里为什么不行啊?把字符型数值转换成长整数据
二.對話框?MessageBox
{
GetData1("select XXXXX from TTTTT"); dataGridView4.DataSource = bindingSource2; GetData1(dataAdapter1.SelectCommand.CommandText);
dataGridView4.Columns["ID"].Visible = false;
}
private void GetData1(string selectCommand1)
{ try
{ String connectionString = ""; dataAdapter1 = new SqlDataAdapter(selectCommand1, connectionString); SqlCommandBuilder commandBuilder1 = new SqlCommandBuilder(dataAdapter1); DataTable table1 = new DataTable();
table1.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter1.Fill(table1);
bindingSource2.DataSource = table1;
dataGridView4.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }
catch (SqlException)
{
MessageBox.Show("错误!");
}
} private void button12_Click(object sender, EventArgs e)
{
if ( bindingSource2.Count == 0)
{
MessageBox.Show("请先查询","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else
{
dataAdapter1.Update((DataTable)bindingSource2.DataSource);
MessageBox.Show("已保存", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
你用我这个试试看 不用自动生成的 改改就可以用了