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;namespace 航空机票预订管理系统
{
public partial class passenger : Form
{
public passenger()
{
InitializeComponent();
}
private void selbtn_Click(object sender, EventArgs e)
{
sendstrsql="SELECT 旅客.身份证号 FROM 旅客";
DataTable dt1=link.dsresult(sendstrsql);
dataGridView1.DataSource=dt1.DefaultView;
}
private bool checkEmpty()//判断四个textbox是否均有输入信息
{
bool result = true;
if (txt_addCname.Text.Trim() == string.Empty)
result = false;
else if (txt_addCsex.Text.Trim() == string.Empty)
result = false;
else if (txt_addCno.Text.Trim() == string.Empty)
result = false;
else if (txt_addCtele.Text.Trim() == string.Empty)
result = false;
return result;
}
private void btn_add_Click(object sender, EventArgs e)
{
if(checkEmpty()==true)//当四个textbox均输入时,才进行插入操作
{try{
sendstrsql="INSERT INTO passenger VALUES('"+ txt_addCname.Text+"','"+ txt_addCsex.Text+"','"+ txt_addCno.Text+"','"+ txt_addCtele.Text+"')";
link.updatedb(sendstrsql);
MessageBox.Show("成功插入数据");}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
else MessageBox.Show("输入不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
} private void button4_Click(object sender, EventArgs e)
{
this.Close();
return;
}
}
}
错误提示我:当前上下文不存在名称sendstrsql和link咋办???
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace 航空机票预订管理系统
{
public partial class passenger : Form
{
public passenger()
{
InitializeComponent();
}
private void selbtn_Click(object sender, EventArgs e)
{
sendstrsql="SELECT 旅客.身份证号 FROM 旅客";
DataTable dt1=link.dsresult(sendstrsql);
dataGridView1.DataSource=dt1.DefaultView;
}
private bool checkEmpty()//判断四个textbox是否均有输入信息
{
bool result = true;
if (txt_addCname.Text.Trim() == string.Empty)
result = false;
else if (txt_addCsex.Text.Trim() == string.Empty)
result = false;
else if (txt_addCno.Text.Trim() == string.Empty)
result = false;
else if (txt_addCtele.Text.Trim() == string.Empty)
result = false;
return result;
}
private void btn_add_Click(object sender, EventArgs e)
{
if(checkEmpty()==true)//当四个textbox均输入时,才进行插入操作
{try{
sendstrsql="INSERT INTO passenger VALUES('"+ txt_addCname.Text+"','"+ txt_addCsex.Text+"','"+ txt_addCno.Text+"','"+ txt_addCtele.Text+"')";
link.updatedb(sendstrsql);
MessageBox.Show("成功插入数据");}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
else MessageBox.Show("输入不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
} private void button4_Click(object sender, EventArgs e)
{
this.Close();
return;
}
}
}
错误提示我:当前上下文不存在名称sendstrsql和link咋办???
解决方案 »
- 有没有办法隐藏第三方的命名空间
- 初学.net在ado.net数据库连接处遇到疑惑,还请各位前辈指教!
- App.config文件修改的小问题?
- ToolStripContainer 或者说某个控件怎么置顶?
- C#,一道面试题,算法如何写呀!能者多劳,谢谢!
- 我手写了一个添加菜单及菜单项程序,为什么运行时看不到菜单?
- 上海软件开发薪资行情,上海工作的兄弟们能不能透漏一点
- c#出学者问题
- 再问kailong(凯龙)?class程序做成托盘后,为什么菜单出不来那?
- 什么是localized satellite assembly错误?
- C# 编译后点击Line,对应的Form2不弹出来,求教
- SQL语句求差问题
1、sendstrsql没有定义是因为你没有声明这个变量就直接使用了,解决办法是在sendstrsql前面加上string
也就是说效果是string sendstrsql,后面的代码保持不变就可以解决了2、link 这个对象应该是你没有引入自定义的命名空间,所以程序中找不到这个对象,也因此无法调用相应的方法