日期:2014-05-18  浏览次数:20845 次

100分
winform    
1.在一个button按钮时查看   以textbox1中的值为名称的表是否存在   不存在则创建以textbox1中的值为名称的表     表的格式是固定的
3.在窗体中的comboBox中自动增加textbox1中的值为名称的表   并从下拉菜单中选中该值时datagird会调出表中的数据
3.输入一个数字     整个表中的数量与数字在表中的倍率的积相减在把结果写在这个表中的数量字段中
我要代码

------解决方案--------------------
这东西没这么简单,干脆lz拿点money偶帮你做
------解决方案--------------------
个人建议数据库不要动态创建,事先设计好并先创建!

另外楼主,这里没有人会提供完整的代码,还是自己好好钻研一下吧,到网上找找例子,应该很简单的!
------解决方案--------------------
up
------解决方案--------------------
友情帮顶!!!关注
------解决方案--------------------
如果你是做软件的
我的回答已经够清楚了
如果你不是的话
那么你拿不到你想要的结果
------解决方案--------------------
http://community.csdn.net/IndexPage/SmartQuestion.aspx#bespecific
http://msdn.microsoft.com/msdnmag/issues/01/05/sqldmo/
------解决方案--------------------
友情UP
------解决方案--------------------
up
------解决方案--------------------
第一个问题:我建了一个按钮button1,一个文本框textBox1,一点击该按钮就会自动监测一下textBox1的表是否存在,如果存在,则会提示:该表已经存在,如果不存在则会建立一张表

private void button1_Click(object sender, EventArgs e)
{
//连接字符串,Data Source是你的Sql所在计算机的名字或者IP地址,
//Initial Catalog为你建表的数据库
String ConnStr = "Data Source=KFSERVICE;Initial Catalog=master;User ID=sa ";
//查指定的表是否存在所用到的sql语句
String sql1 = "select count(*) from sysobjects where name= ' " + this.textBox1.Text.ToString().Trim()+ " ' and type= 'U ' ";
//创建表的sql语句
String sql2= "create table "+this.textBox1.Text.ToString().Trim()+ "(id int primary key,name varchar(20)) ";
SqlConnection conn =null;
SqlCommand command =null;
SqlDataReader reader =null;
conn= new SqlConnection(ConnStr);
if(conn.State==ConnectionState.Closed)
conn.Open();

command = new SqlCommand(sql1, conn);
reader=command.ExecuteReader();
String num= " ";
if(reader.Read())
{
num=reader.GetInt32(0).ToString();
reader.Close();
}
//此表存在
if(num.ToString().Equals( "1 "))
{
if (conn.State == ConnectionState.Open)
conn.Close();
MessageBox.Show( "此表已经存在! ");

}
//不存在,创建你指定的表
else
{
try{
if (conn.State == ConnectionState.Closed)
conn.Open();
command=new SqlCommand(sql2,conn);
command.ExecuteNonQuery();
MessageBox.Show( "此表已经建立完毕! ");
}
catch(Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}