473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

about create table in sqlcommand

hi
i know how can i create a table with sql command
but i don't know how create a field with type integer ,autoNumber
(auto increase) and Primary key
Like id field in Access

may you change below code with add a field with above properties
Create Table " + TextBox1.Text + "(tex varchar ,topic
varchar(25)PRIMARY KEY)
thanks

Feb 1 '07 #1
2 1830
Hello miladhatam,

What I think you're asking is how to create a table with a primary key that
is also an identity column. The following statement creates the MyCustomers
table with a CustID field/column as the primary key as an IDENTITY integer
which starts at 100 and increases at an increment of 1. It also has a
CompanyName column. Check out SQL Online Books:

CREATE TABLE MyCustomers (CustID INTEGER IDENTITY (100,1) PRIMARY KEY,
CompanyName NvarChar (50))

--
brians
http://www.limbertech.com
"mi********@gmail.com" wrote:
hi
i know how can i create a table with sql command
but i don't know how create a field with type integer ,autoNumber
(auto increase) and Primary key
Like id field in Access

may you change below code with add a field with above properties
Create Table " + TextBox1.Text + "(tex varchar ,topic
varchar(25)PRIMARY KEY)
thanks

Feb 1 '07 #2

brians äæÔÊå ÇÓÊ:
Hello miladhatam,

What I think you're asking is how to create a table with a primary key that
is also an identity column. The following statement creates the MyCustomers
table with a CustID field/column as the primary key as an IDENTITY integer
which starts at 100 and increases at an increment of 1. It also has a
CompanyName column. Check out SQL Online Books:

CREATE TABLE MyCustomers (CustID INTEGER IDENTITY (100,1) PRIMARY KEY,
CompanyName NvarChar (50))

--
brians
http://www.limbertech.com
"mi********@gmail.com" wrote:
hi
i know how can i create a table with sql command
but i don't know how create a field with type integer ,autoNumber
(auto increase) and Primary key
Like id field in Access

may you change below code with add a field with above properties
Create Table " + TextBox1.Text + "(tex varchar ,topic
varchar(25)PRIMARY KEY)
thanks
oh thanks
i find this code
id INT NOT NULL IDENTITY PRIMARY KEY ,tex varchar ,topic varchar(25))
but your code is better

Feb 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom | last post by:
1. I drag the sqlDataAdapter and sqlConnection from the tool bar to the web form. It creates automatically: protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; protected...
0
by: Richard Blewett [DevelopMentor] | last post by:
using System; using System.Data; using System.Data.SqlClient; class App { static void Main(string args) { string SQL = @"Create table Foo (
0
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the...
3
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
6
by: Joe | last post by:
Hi, I have a MS Access DB in which a record has just too many fields to be able to allow users to do inline editing in a datagrid. So I want to display as First Name: Text box where first...
9
by: Peter | last post by:
Hello£¬everyone, My program will collect a testing machine's data ,save the data and deal with the data everyday. I want to use vb.net to create database, add and delete tables or modify the...
0
by: godsmustbcrazy | last post by:
Here is my problem. Brand new SQL Server 2005 Installation 1. Create a database "Test" 2. Create a database user "Domain\user" and set user mapping to "Test" with datareader, datawriter...
1
by: =?Utf-8?B?QmlsIENsaWNr?= | last post by:
I wrote a stored procedure that runs fine when I execute from SQL 2005 Management Studio, and runs ok when I step into it from VS2005. Both return a value of 0, drop, create & populate the table. ...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.