Hy,
I have wrote in asp.net the next code: - using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.Data.SqlClient;
-
public partial class Default2 : System.Web.UI.Page
-
{
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
-
}
-
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
-
{
-
TextBoxData.Text = Calendar1.SelectedDate.ToString();
-
}
-
protected void Button1_Click(object sender, EventArgs e)
-
{
-
try
-
{
-
-
string connString = "Initial Catalog=PEOPLE;Data Source=John-4E29FADEE;Integrated Security=SSPI;";
-
SqlConnection conn = new SqlConnection(connString);
-
conn.Open();
-
Response.Write("Successful connection!");
-
SqlCommand comanda = new SqlCommand();
-
comanda.Connection = conn;
-
comanda.CommandType = System.Data.CommandType.Text;
-
-
comanda.CommandText = "INSERT INTO dbo.PERSON VALUES (" + TextBoxID.Text + "," + TextBoxName.Text + "," + TextBoxInitiala.Text + "," + TextBoxLastName.Text + "," + TextBoxData.Text + "," + TextBoxCNP.Text + "," + TextBoxMother.Text + "," + TextBoxFather.Text + ")";
-
int no = comanda.ExecuteNonQuery();
-
-
Response.Write("No of affected rows = " + no);
-
conn.Close();
-
-
}
-
catch (SqlException exc)
-
{
-
Response.Write("Error " + exc.Message);
-
}
-
-
}
-
-
}
And i get the message: Successful connection! Error Incorrect syntax near ','
I looked many times but I can not figure out what's wrong
Please help me
1 4679
Your insert query must be changed as : -
comanda.CommandText = "INSERT INTO dbo.PERSON VALUES (" + TextBoxID.Text + ",'" + TextBoxName.Text + "','" + TextBoxInitiala.Text + "','" + TextBoxLastName.Text + "','" + TextBoxData.Text + "','" + TextBoxCNP.Text + "','" + TextBoxMother.Text + "','" + TextBoxFather.Text + "')";
-
assuming Name,Initials,Lastname,Data,BoxCNP,Mother,Father to be as varchar /string type in the database.
The format to insert/retrieve all string type declared values in the database from C# is
and for all fields declared in numeric category is
.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Amit D.Shinde |
last post by:
Hi Experts,
i am writting a stored procedure in sql server 7. Its a simple stored
procedure
It is my first stored procedure.
I want insert a record in table if the primary key field user id...
|
by: Mark Findlay |
last post by:
Hello Experts!
I am attempting to use the OleDbCommand.ExecuteScaler() function within my
ASP.NET C# web page to perform a simple validation, but receive the
following error:
"Incorrect...
|
by: Dax |
last post by:
When i insert some values float in a form made with ASP
appear an error message like this:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near ','.
sql="select...
|
by: mabubakarpk |
last post by:
HI.
I am using SQL Server 2000. I generate a script of some table from EmpDB database when I run script in query analyzer it return error "Incorrect syntax near 'COLLATE'."
Scripts is
...
|
by: roamnet |
last post by:
hi
i created database file with .mdf extention ,sql server as a source
and use grid view to display data
there're no problem in data retrieve and display,but i want to edit it
or insert new...
|
by: Mark B |
last post by:
When I click the 'Update' button on a ASP.Net 3.5 GridView record, I get an
error:
Incorrect syntax near 'nvarchar'.
Everything else there works OK. Here is the code:
<%@ Page...
|
by: Mia Archibald |
last post by:
SELECT mcr2008.st, (SUM(mcr2008.bedsize)-SUM(mcr2007.bedsize))/SUM(mcr2007.bedsize)
FROM
(
(
SELECT mcrid, st , SUM(bedsize) as bedsize
FROM MCRCR_96_to_08
WHERE...
|
by: silwar |
last post by:
Hi,
I have already stored value of author id in list item value while page loads. but when I change index of drop down list to view author information error is shown. I tried to debug using check...
|
by: juhii3102 |
last post by:
protected void btn_Edit_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
Button5.Visible = true;
if (FileUpload1.HasFile)
{
//string...
|
by: syedshaffee |
last post by:
Hey people,
i am getting this error 'Incorrect syntax near the keyword 'EXISTS'.'
while executing this query
SELECT Contract_detail.Contract_no
FROM Contract_detail INNER JOIN...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| | |