473,394 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Updating table

103 100+
Hi all,
I am trying to update a table...

I have a gridview which is having the records of a table..
i have a link field called 'Update'. when i click on that link, the corresponding values in the grid will displayed on textboxes on the same page.

i want to update the values available in the textboxes..
But i cant update it..

Updation is not done..

plz help me..

regards,
mathew
Sep 25 '07 #1
3 955
davef
98
Please post your code. Without it, it's hard to impossible to help you.
Sep 25 '07 #2
mathewgk80
103 100+
Please post your code. Without it, it's hard to impossible to help you.
Hi,

This is my code..

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class NewCategories : System.Web.UI.Page
{
public string cid;
public string cname;
string description;
private SqlConnection con;
string connection = ConfigurationManager.AppSettings["connection"].ToString();
protected void Page_Load(object sender, EventArgs e)
{

try
{
string qstring = Request.QueryString[0].ToString();
string[] qryarr = new string[1];

int index = qstring.IndexOf(',');

int len = qstring.Length;

int leng = len - (index + 1);
cid = qstring.Substring(0, index);

string restValues = qstring.Substring(index + 1, leng);
int indexrestofvalues = restValues.IndexOf(',');
int lengthrestofvalues = restValues.Length;

int lencname = lengthrestofvalues - indexrestofvalues;

cname = restValues.Substring(0, indexrestofvalues);
description = restValues.Substring(indexrestofvalues + 1, lencname - 1);
txtCatID.Text = cid;
txtName.Text = cname;
txtDescription.Text = description;
txtName.Text = txtName.Text;
txtDescription.Text = txtDescription.Text;

}
catch (Exception)
{

}






}

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow r = GridView1.Rows[e.RowIndex];


}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string status;

//GridView1.DataBind();
con = new SqlConnection(connection);
con.Open();
status = con.State.ToString();
string a = txtName.Text;
txtName.Text = a;



SqlCommand cmd1 = new SqlCommand("update Categories set CategoryName='" + txtName.Text + "',Description='" + txtDescription.Text + "' where CategoryID=" + cid + " ", con);
cmd1.ExecuteNonQuery();

con.Close();

GridView1.DataBind();


//}


}


}
Sep 25 '07 #3
davef
98
Two things to check in debug:
  • Actual update query string
  • Result of ExecuteNonQuery() method
Sep 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: Srinadh | last post by:
Hi all, We have files with about 20 to 30 fields per row. We are trying to update such files with about 60 rows as contiguous data in a CLOB field. It passes through. But when we try...
1
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't...
1
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... ...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
2
by: Alexey.Murin | last post by:
The application we are developing uses MS Access 2003 database (with help of ADO). We have noticed that during massive records updating the size of the mdb file increases dramatically (from 3-4 to...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.