TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
paddylast
NA
12
0
Datagrid update
Oct 7 2004 5:42 PM
I get the following error: Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'Email'. when I hit the update button on my datagrid. Can anyone help on this? Here is the code: I've added a datagrid to my form as follows in html: In codebehind public void grdPlayers_Update(Object sender, DataGridCommandEventArgs e) { String updateCmd = "UPDATE Players SET Surname = @Surname, FirstName = @FirstName, League = @League, " + "LeaguePosition = @LeaguePosition, Ladder = @Ladder, PhoneHome = @PhoneHome, PhoneWork = @PhoneWork, PhoneMobile = @PhoneMobile Email = @Email where Id = @Id"; SqlCommand myCommand = new SqlCommand(updateCmd, connSquash); myCommand.Parameters.Add(new SqlParameter("@Surname", "Surname")); myCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.VarChar, 30, "FirstName")); myCommand.Parameters.Add(new SqlParameter("@League", SqlDbType.Int, 4, "League")); myCommand.Parameters.Add(new SqlParameter("@LeaguePosition", SqlDbType.Int, 4, "LeaguePosition")); myCommand.Parameters.Add(new SqlParameter("@Ladder", SqlDbType.Int, 4, "Ladder")); myCommand.Parameters.Add(new SqlParameter("@PhoneHome", SqlDbType.VarChar, 20, "PhoneHome")); myCommand.Parameters.Add(new SqlParameter("@PhoneWork", SqlDbType.VarChar, 20, "PhoneWork")); myCommand.Parameters.Add(new SqlParameter("@PhoneMobile", SqlDbType.VarChar, 20, "PhoneMobile")); myCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 30, "Email")); myCommand.Parameters.Add(new SqlParameter("@Id", System.Data.SqlDbType.SmallInt, 2, "Id")); myCommand.Parameters["@Id"].Value = grdPlayers.DataKeys[(int)e.Item.ItemIndex]; myCommand.Connection.Open(); myCommand.ExecuteNonQuery(); grdPlayers.EditItemIndex = -1; myCommand.Connection.Close(); BindData(); } Thanks.
Reply
Answers (
3
)
How to generate a bar code?
Datagrid update 2