473,401 Members | 2,127 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,401 software developers and data experts.

Database not updating: no errors

Hi,

In the below code its not showing any error but its not updating:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Data;
  9.  
  10. public partial class VendorDetails : System.Web.UI.Page
  11. {
  12.     protected void Page_Load(object sender, EventArgs e)
  13.     {
  14.         gridViewDataBind();
  15.     }
  16.     protected void LinkButton1_Click(object sender, EventArgs e)
  17.     {
  18.         Response.Redirect("AddDetails.aspx");
  19.     }
  20.     //protected void gvVendor_RowCancellingEdit(object sender, GridViewCancelEditEventArgs e)
  21.     //{
  22.     //    gvVendor.EditIndex = -1;
  23.     //}
  24.     protected void gridViewDataBind()
  25.     {
  26.         string strcon = System.Configuration.ConfigurationManager.ConnectionStrings["VendorNewConnectionString"].ConnectionString;
  27.         SqlConnection Objcon = new SqlConnection(strcon);
  28.         //DataSet Questions = new DataSet();                      
  29.         DataTable dtGrid = new DataTable();
  30.         SqlDataAdapter da;
  31.         Objcon.Open();
  32.         SqlCommand oCmd = new SqlCommand("gridSelect", Objcon);
  33.         oCmd.CommandType = CommandType.StoredProcedure;
  34.         da = new SqlDataAdapter(oCmd);
  35.         da.Fill(dtGrid);
  36.         Objcon.Close();
  37.         gview.DataSource = dtGrid;
  38.         gview.DataBind();
  39.     }
  40.  
  41.  
  42.  
  43.     //protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  44.     //{
  45.  
  46.     //}
  47.  
  48.     //protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  49.     //{
  50.     //    gvVendor.EditIndex = e.NewEditIndex;
  51.     //}
  52.  
  53.     protected void gview_RowUpdating(object sender, GridViewUpdateEventArgs e)
  54.     {
  55.         int rowindex = e.RowIndex;
  56.  
  57.         TextBox TextBox1 = new TextBox();
  58.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtaddress1");
  59.         string address1 = TextBox1.Text;
  60.  
  61.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtaddress2");
  62.         string address2 = TextBox1.Text;
  63.  
  64.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtVendorName");
  65.         string VendorName = TextBox1.Text;
  66.  
  67.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtAnnualrevenue");
  68.         int Annualrevenue = Convert.ToInt32(TextBox1.Text.ToString());
  69.  
  70.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtEmailId");
  71.         string EmailId = TextBox1.Text;
  72.  
  73.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtWebsite");
  74.         string Website = TextBox1.Text;
  75.  
  76.         TextBox1 = (TextBox)gview.Rows[rowindex].FindControl("txtVendorSince");
  77.         DateTime VendorSince = Convert.ToDateTime(TextBox1.Text.ToString());
  78.  
  79.         Label lblVendor = (Label)gview.Rows[rowindex].FindControl("lblVendorId");
  80.         int iVendorID = Convert.ToInt32(lblVendor.Text.ToString());
  81.  
  82.         SqlConnection Objcon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["VendorNewConnectionString"].ConnectionString);
  83.         Objcon.Open();
  84.         SqlCommand oCmd = new SqlCommand("sp_UpdateGrid", Objcon);
  85.  
  86.         oCmd.Parameters.AddWithValue("@VendorName", VendorName);
  87.         oCmd.Parameters.AddWithValue("@Email", EmailId);
  88.         oCmd.Parameters.AddWithValue("@Website", Website);
  89.         oCmd.Parameters.AddWithValue("@Add1", address1);
  90.         oCmd.Parameters.AddWithValue("@Add2", address2);
  91.         oCmd.Parameters.AddWithValue("@VendorSince", VendorSince);
  92.         oCmd.Parameters.AddWithValue("@AnnRev", Annualrevenue);
  93.         oCmd.Parameters.AddWithValue("@VID", iVendorID);
  94.  
  95.         oCmd.CommandType = CommandType.StoredProcedure;
  96.         oCmd.ExecuteNonQuery();
  97.         Response.Write("successfully updated");
  98.         Objcon.Close();
  99.         gridViewDataBind();
  100.         gview.EditIndex = -1;
  101.     }
  102.  
  103.     protected void gview_RowEditing(object sender, GridViewEditEventArgs e)
  104.     {
  105.        gview.EditIndex = e.NewEditIndex;
  106.     }
  107.  
  108.     protected void gview_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  109.     {
  110.         gview.EditIndex = -1;
  111.     }
  112. }
  113.  
Apr 12 '12 #1
1 1380
Rabbit
12,516 Expert Mod 8TB
What's not updating?
Apr 12 '12 #2

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

Similar topics

4
by: Max Harvey | last post by:
Hi, I have looked at the example called "Open Parameter queries from code" from the site http://www.mvps.org/access/queries/qry0003.htm I made up a test which I though looked pretty close...
0
by: Santosh | last post by:
Hii, I am developing web application using asp.net with in that i am using crytal report for showing reports. it works fine on local machine but when i deploy it on the web server it gives me key...
1
by: tehxd | last post by:
I having a table something like this: startdate | stime | endate | etime | tool 3/3/07 | 8:47 | 3/4/07 | 00:30 | A 3/4/07 | 3:57 | 3/4/07 | 4:30 | B 3/4/07 | 8:21 | ...
1
by: smartchap009 | last post by:
Adding,Updating and Deleting user using perl script in linux -------------------------------------------------------------------------------- hi, If i can get help in writing perl code for...
6
by: manjitsarma | last post by:
In the following code I am getting the error-' the modifier public is not valid for this item'.Error is showing in 'getAvr'- public interface student { public double...
1
by: nRk | last post by:
Hi, I am working on asp.net 2.0 with Visual Studio 2005. My asp.net project contains one Masterpage. I exposed my asp.net project in my machine (Windows XP with IIS 5.1) and access using...
2
by: Smurfas | last post by:
What's wrong? Compiletor don't show anything, but whet I start program show this error: "Error updating the employee details!" protected void Button1_Click(object sender, EventArgs e) ...
2
Kosal
by: Kosal | last post by:
Dear All Can you help me to convert as below code to vb.net module Function GF_ListGroupsOfUser(ByVal stUserName As String) As String On Error GoTo err_ListGroupsOfUser Dim...
2
by: Leonidas Savvides | last post by:
HOW detect EOF at below code? what put in place of ( i<3306 ) ??? public mergerTxt() { try { File file = new File( "us-skype.lang" ); // get file name File fileRu = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.