声明数据类型时出错 [英] Error In Declaring Data Type

查看:78
本文介绍了声明数据类型时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨frnds ...

Am创建一个动态创建数据库表的应用程序现在我需要将我的数据类型varchar(max)更改为int也设置主键和自动增加值pls指导我...我收到一个错误



Hi frnds...
Am Creating an application which the database table is created dynamically the thing is now i need to change my data type varchar(max) to int also to set an primary key and Auto incremnt the value pls do guide me...I got an error as

In Correct Syntax near Int32





这是我的代码





Here is my code

foreach (DataColumn dc in dt.Columns)
               {
                   if (exists == null)
                   {
                       SqlCommand createtable = new SqlCommand("CREATE TABLE " + TextBox1.Text + " (" + TextBox1.Text.Substring(0, 1) + "ID" + " sizeof(Int32) )", con);
                       createtable.ExecuteNonQuery();
                       exists = dt.TableName;
                   }

               }


               SqlCommand addcolumn = new SqlCommand("ALTER TABLE " + TextBox1.Text + " ADD " + TextBox2.Text + " varchar(MAX)," + TextBox3.Text + " varchar(MAX) ," + TextBox4.Text + " varchar(MAX)," + TextBox5.Text + " varchar(MAX)," + TextBox6.Text + " varchar(MAX)," + TextBox7.Text + " varchar(MAX)," + TextBox8.Text + " varchar(MAX)", con);
               addcolumn.ExecuteNonQuery();
               Session["tablename"] = TextBox1.Text.ToString();

               break;







谢谢..,




Thank You..,

推荐答案

问题是sizeof(int32)删除它并保持bigint
problem is sizeof(int32) remove it and keep bigint


这篇关于声明数据类型时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆