faramarz_s
جمعه 04 مهر 1382, 17:35 عصر
خیلی به این چند خط ور رفتم اما خطای زیرش را میدهد:
String insertCmd1 =
"INSERT INTO tblSupplemental(id,fn,shsh,born_date,Address,tel,p ostcode,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 ()
+"')";
SqlCommand sqlcommandUsers = new SqlCommand(insertCmd1, sqlconnectionForum);
sqlcommandUsers.Connection.Open();
sqlcommandUsers.ExecuteNonQuery();
sqlcommandUsers.Connection.Close();
DataSet datasetUsers = new DataSet();
sqldataadapterUsers.Fill(datasetUsers, "tblSupplemental");
}
catch (Exception ex)
{
Label9.Text=ex.Message.ToString();
}
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
String insertCmd1 =
"INSERT INTO tblSupplemental(id,fn,shsh,born_date,Address,tel,p ostcode,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 ()
+"')";
SqlCommand sqlcommandUsers = new SqlCommand(insertCmd1, sqlconnectionForum);
sqlcommandUsers.Connection.Open();
sqlcommandUsers.ExecuteNonQuery();
sqlcommandUsers.Connection.Close();
DataSet datasetUsers = new DataSet();
sqldataadapterUsers.Fill(datasetUsers, "tblSupplemental");
}
catch (Exception ex)
{
Label9.Text=ex.Message.ToString();
}
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