Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Edit SQL table script?

$
0
0

I have been having numerous errors relating back to my INSERT string in my code-behind (written in C#). It started with "Error code 213: Column name or number of supplied values does not match table definition." I found an error in one instance and simply added the column headings to the other. (i.e. INSERT INTO log (col1,col2,col3) VALUES 'x', 'y', 'z'). The latest I have gotten is this:

(TABLE 1)
Error code 515: Cannot insert the value NULL into column 'ResID', table 'B&B.dbo.Reservations'; column does not allow nulls. INSERT fails. The statement has been terminated.

(TABLE 2)
Error code 110: There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

I believe the issue is because I didn't specify a start value for the primary ID. I verified this by going into SQL SERVER MANAGEMENT STUDIO and viewing my table script. The create portion is below.

Can I alter this to include something like [identity(100,1)] ?

CREATE TABLE [dbo].[Reservations](
	[ResID] [smallint] NOT NULL,
	[CustomerName] [varchar](50) NOT NULL,
	[Phone] [varchar](10) NOT NULL,
	[Email] [varchar](50) NULL,
	[Arrive] [date] NOT NULL,
	[Depart] [date] NOT NULL,
	[Room] [varchar](20) NOT NULL,
	[CardType] [varchar](10) NOT NULL,
	[CreditCard] [varchar](16) NOT NULL,
	[Discount] [varchar](5) NULL,
	[TotalDue] [money] NOT NULL,
 CONSTRAINT [PK_Reservations] PRIMARY KEY CLUSTERED

Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>