哪位大侠给指点一下啊
来源:互联网 发布:淘宝店铺设置运费险 编辑:程序博客网 时间:2024/05/01 09:59
关于自定义表单,我的思路是记录创建表单的项然后通过SQL过程创建数据表可是老是提示类型异常请各位帮忙看下到底哪里错了,谢谢
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- 根据要求创建表单
-- =============================================
ALTER PROCEDURE [dbo].[CreateTables]
@tablename nvarchar(100), --表名
@str nvarchar(1000) --字段
AS
declare @sql nvarchar(1100)
set @sql=''
BEGIN
set @sql='create table'+' '+@tablename+'('+@str+')'+';'
print @sql
execute (@sql)
--create table @tablename (@str)
END
asp.net调用如下
/// <summary>
/// connect 为连接字符串
/// process 为过程名
/// Sda为 SQL数据适配器
/// </summary>
SqlConnection connect;
SqlCommand process;
SqlDataAdapter Sda;
private string connectionString = ConfigurationManager.ConnectionStrings["oasysConnectionString"].ConnectionString;
public WorkFlow()
{
connect = new SqlConnection(connectionString);
this.process = connect.CreateCommand();
Sda = new SqlDataAdapter(this.process);
}
public void CreateTables(string names, string strs)
{
connect.Open();
process = new SqlCommand("CreateTables", connect);
process.CommandType = CommandType.StoredProcedure;
SqlParameter tablename = new SqlParameter("@tablename", SqlDbType.NVarChar, 100);
tablename.Value = names;
process.Parameters.Add(tablename);
SqlParameter str = new SqlParameter("@str", SqlDbType.NVarChar, 1000);
str.Value = strs;
process.Parameters.Add(str);
runprocess();
}
private void runprocess()
{
try
{
process.ExecuteNonQuery();
}
catch (Exception ex)
{
ex = new Exception("操作失败!");
throw ex;
}
finally
{
connect.Close();
}
}
页面文件
WorkFlow.WorkFlow WorkFlow = new WorkFlow.WorkFlow();
static string str = "";
static string route = "";
protected void Page_Load(object sender, EventArgs e)
{
//UpdatePanel1.Visible = true;
//UpdatePanel2.Visible = false;
//UpdatePanel3.Visible = false;
//if (!Page.IsPostBack)
//{
//}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
WorkFlow.CreateWorkFlowTable(TextBox1.Text, "id", "int", "0", "IDENTITY(1,1) NOT NULL PRIMARY KEY", TextBox2.Text);
pClass.MessageBoxShow("创建表成功", "", Page);
str = TextBox1.Text + " " + "id" + " " + "int" + " " + "" + "IDENTITY(1,1) NOT NULL PRIMARY KEY"; //str记录创建表单的字段参数
UpdatePanel1.Visible = false;
UpdatePanel2.Visible = true;
UpdatePanel3.Visible = false;
tablenames.Text = TextBox1.Text;
}
catch
{
pClass.MessageBoxShow("创建表失败", "", Page);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
WorkFlow.CreateWorkFlowTable(tablenames.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text,TextBox7.Text);
pClass.MessageBoxShow("创建字段成功", "", Page);
str += "," + tablenames.Text + " " + TextBox3.Text + " " + TextBox4.Text + "(" + TextBox5.Text+")"+ " " + TextBox6.Text + " " + TextBox7.Text;
GridView1.DataBind();
TextBox7.Text = "";
TextBox6.Text = "";
TextBox5.Text = "";
TextBox4.Text = "";
TextBox3.Text = "";
//待定
}
catch
{
pClass.MessageBoxShow("创建字段失败", "", Page);
}
}
protected void Button3_Click(object sender, EventArgs e)
{
UpdatePanel1.Visible = false;
UpdatePanel2.Visible = false;
UpdatePanel3.Visible = true;
}
protected void Button4_Click(object sender, EventArgs e)
{
GridView3.DataBind();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Label Label1 = (Label)GridView3.FindControl("Label1");
TextBox TextBox8 = (TextBox)UpdatePanel3.FindControl("TextBox8");
TextBox8.Text = Label1.Text;
}
protected void Button5_Click(object sender, EventArgs e)
{
route += TextBox8.Text + "-";
str += "," + tablenames.Text + " " + TextBox8.Text + "sh" + " " + "nvarchar(200)" + " ";
WorkFlow.CreateWorkFlowTable(tablenames.Text, TextBox8.Text + "sh", "nvarchar(200)", "200", "", "");
TextBox8.Text = "";
TextBox9.Text = "";
//pClass.MessageBoxShow("节点输入成功", "");
routelabel.Text = route;
UpdatePanel3.DataBind();
}
protected void Button6_Click(object sender, EventArgs e)
{
//route += "'";
str += "," + "route" + " " + "nvarchar(500)" + " " + "default " + route;//记录流程节点
str += "," + "currents" + " " + "nvarchar(500)";//记录到哪里了
//str+=","+"
///daixu!!!!!!!!!!!!!!!!!!!!!!!!
}
protected void Button7_Click(object sender, EventArgs e)
{
try
{
WorkFlow.CreateTables(tablenames.Text, str);
pClass.MessageBoxShow("创建成功", "", Page);
}
catch
{
}
}
敢问我错在哪里了 谢谢
- 哪位大侠给指点一下啊
- 使用ireport做pdf报表,生成的pdf一直都是文件损坏,无法打开,哪位大侠指点一下
- 有哪位高手指点一下 小弟感激不尽
- 很想学习PHP框架 希望哪位高人可以指点一下
- 240320的显示 ,哪位高手能够指点一下!
- 关于fstream 存储类对象,大侠指点一下
- 为什么java投简历没人打电话让去面试,哪位高人给指点指点?
- 哪位大侠赐教,怎么能拿到积分啊,无奈中~~~~
- 哪位大侠帮帮忙啊(java邻接表的初始化)
- 请内行人给指点一下,不胜感激
- 各位老大给指点一下JSP错误
- 求助!哪位大侠出手相助一下,算法设计题,急急急
- 请问哪位大侠能帮忙对比一下2块笔记本硬盘hts723225l9a360的性能优劣?
- 希望各位大侠指点!
- 请大侠们指点
- 求大侠指点方向
- 小弟写了两个socket点对点编程但都只通了一半,哪位大侠给俺看看??
- 如何在特定的区域提问?请哪位高手帮忙指点一下,谢谢!
- Informix数据库调优
- IT人 如何休息
- inux系统下的Gcc的基本使用
- 【转】PL/SQL Developer 设置快捷键
- 证券交易软件开发
- 哪位大侠给指点一下啊
- 不同的编译器:GCC G++ C C++的区别
- sql2000 和sql2005分页存储过程
- 在flash builder的纯actionscript工程中导入flex组件
- 两分钟让你明白什么是ERP
- .net批量导入数据
- TShockwaveFlash的安装及其属性和方法
- 技术总监和CTO的区别 浅谈CTO的作用----软件公司如何开源节流(一)
- BIRT Viewer 参数设置详解