shahab Posted September 26, 2003 Posted September 26, 2003 I had changed this codes a lot but... String insertCmd1 = "INSERT INTO tblSupplemental(id,fn,shsh,born_date,Address,tel,postcode,faf,memoir,degree,un,gd,po,mp,smd,emd) "+ "VALUES(" +TextBox1.Text.Trim() +",N'" + TextBox2.Text.Trim () +"',"+ TextBox3.Text.Trim () +",N'"+TextBox4.Text.Trim() +"',N'"+ TextBox5.Text.Trim () +"',N'"+TextBox6.Text.Trim () +"',N'"+ TextBox7.Text.Trim () +"',N'"+TextBox8.Text.Trim () +"',N'"+ TextBox9.Text.Trim () +"',N'"+TextBox10.Text.Trim () +"',N'"+ TextBox11.Text.Trim () +"','"+TextBox12.Text.Trim () +"',N'"+ TextBox13.Text.Trim () +"',"+ TextBox14.Text.Trim () +",N'"+ TextBox15.Text.Trim () +"',N'"+ TextBox16.Text.Trim () +"')"; it said: Line 1: Incorrect syntax near ',' if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblSupplemental]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tblSupplemental] GO CREATE TABLE [dbo].[tblSupplemental] ( [id] [int] NOT NULL , [fn] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [shsh] [int] NULL , [born_date] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Address] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [tel] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [postcode] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [faf] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [memoir] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [degree] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [un] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [gd] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [po] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [mp] [int] NULL , [smd] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [emd] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO help! Quote
barski Posted September 27, 2003 Posted September 27, 2003 What are all the N for. Also, I don't think the + sign works in asp.net try & Quote
Moderators Robby Posted September 27, 2003 Moderators Posted September 27, 2003 barski, + is used in C#, N is used in SQL Server. Quote Visit...Bassic Software
shahab Posted September 27, 2003 Author Posted September 27, 2003 The program is in c# therer for + is true! N is used for national characters (MS SQL SERVER)and is also true! You could not help me!:( it said: Line 1: Incorrect syntax near ',' :confused: Quote
Moderators Robby Posted September 28, 2003 Moderators Posted September 28, 2003 I reformated the string just for ease of reading, try it out. Also, Make sure that the columns mark as Int are indeed int in the table. I'm sure that you're doing some Server-side validation to ensure that there are no nulls, etc... String insertCmd1 = "INSERT INTO tblSupplemental(" + "id,fn,shsh,born_date," + "Address,tel,postcode,faf," + "memoir,degree,un,gd," + "po,mp,smd,emd) " + "VALUES(" + textBox1.Text.Trim() + ", " + "N'" + textBox2.Text.Trim() + "'," + Convert.ToInt32(textBox3.Text) + ", " + "N'" + textBox4.Text.Trim() + "'," + "N'" + textBox5.Text.Trim() + "'," + "N'" + textBox6.Text.Trim() + "'," + "N'" + textBox7.Text.Trim() + "'," + "N'" + textBox8.Text.Trim() + "'," + "N'" + textBox9.Text.Trim() + "'," + "N'" + textBox10.Text.Trim()+ "'," + "N'" + textBox11.Text.Trim() + "'," + "'" + textBox12.Text.Trim() + "'," + "N'" + textBox13.Text.Trim() + "'," + Convert.ToInt32(textBox14.Text) + "," + "N'" + textBox15.Text.Trim() + "'," + "N'" + textBox16.Text.Trim() + "')"; Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.