Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

Posted

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:

  • Moderators
Posted

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() + "')"; 

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...