Click here to Skip to main content
15,910,121 members
Home / Discussions / C#
   

C#

 
GeneralRe: ServerVersion Exception being thrown Pin
Abhijit Jana24-Jul-09 8:40
professionalAbhijit Jana24-Jul-09 8:40 
GeneralRe: ServerVersion Exception being thrown Pin
MWRivera24-Jul-09 8:51
MWRivera24-Jul-09 8:51 
GeneralRe: ServerVersion Exception being thrown Pin
Abhijit Jana24-Jul-09 9:03
professionalAbhijit Jana24-Jul-09 9:03 
GeneralRe: ServerVersion Exception being thrown Pin
MWRivera24-Jul-09 9:08
MWRivera24-Jul-09 9:08 
GeneralRe: [Message Deleted] Pin
Abhijit Jana24-Jul-09 8:43
professionalAbhijit Jana24-Jul-09 8:43 
GeneralRe: [Message Deleted] Pin
MWRivera24-Jul-09 8:53
MWRivera24-Jul-09 8:53 
AnswerRe: ServerVersion Exception being thrown Pin
MWRivera27-Jul-09 4:12
MWRivera27-Jul-09 4:12 
Questionproblem in DELETING rows from gridview and database table using a check box column and a DELETE button. Pin
Omar Akhtar Sheikh24-Jul-09 6:26
Omar Akhtar Sheikh24-Jul-09 6:26 
First of all when I select multiple rows to delete then it gives me an error:
"Uncomitted new rows cannot be deleted."

Secondly, if I select only one row at a time and click the delete button then it deletes all the rows from the database table.


[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using Dotnet67.Sales.DAL;
using Dotnet67.Sales.Items;
using Dotnet67.Sales.Persons;
using System.Data.SqlClient;

namespace Dotnet67.Sales.DAL
{
      public class DALHelper
      {
            private readonly string CONSTRING3 = "CASHIER1";
            private readonly string CONSTRING5 = "DELETE1";

            //   THE FOLLOWING IS THE CODE WHERE I GET ERRORS
            public void DeleteUser(int id)
            {
                  SqlTransaction tran = con.BeginTransaction();
                  SqlConnection con = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
                  SqlCommand com = new SqlCommand(CONSTRING5, con);
                  com.CommandType = CommandType.StoredProcedure;
                  com.Parameters.AddWithValue("@CashierID", id);
                 
                  con.Open();
                  com.ExecuteNonQuery();
                  con.Close();

            }

            public void InsertIntoCashier(string[] str,int[] val)
            {
                  SqlConnection con = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
                  SqlCommand com = new SqlCommand(this.CONSTRING3, con);
                  com.CommandType = CommandType.StoredProcedure;
                 
                  com.Parameters.AddWithValue("@CashierID", val[0]);
                  com.Parameters.AddWithValue("@CashierName", str[0]);
                  con.Open();
                  try
                  {
                     com.ExecuteNonQuery();
                  }
                  finally
                  {
                        con.Close();
                  }
            }

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dotnet67.Sales.DAL;
using Dotnet67.CommonTypes;
using Dotnet67.WinControls;
using System.Data.Sql;
using System.Data.SqlClient;

namespace Dotnet67.Sales.WinUI
{
      public partial class ManageCashier : Form
      {
            public ManageCashier()
            {
                  InitializeComponent();
            }

            private readonly string CONSTRING5 = "DELETE1";
        
            private void ManageCashier_Load(object sender, EventArgs e)
            {
                  // TODO: This line of code loads data into the 'dotnet67DataSet8.Cashier_2' table. You can move, or remove it, as needed.
                  this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
        
            }

            //This is the button for inserting values into grid view which is running perfect.
            private void btnDB_Click(object sender, EventArgs e)
            {
                  DALHelper dH = new DALHelper();
        
                  string[] str = new string[3];
                  int[] values = new int[3];
                  str[0] = txtName.Text;

                  dH.InsertIntoCashier(str, values);
              
                  dataGridView1.Refresh();
                  dataGridView1.RefreshEdit();
                  this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
                 
            }

            // THIS IS THE DELETE BUTTON ON MY FORM WHERE I AM GETTING PROBLEM
            private void btnDELETE_Click(object sender, EventArgs e)
            {
                  DALHelper dH = new DALHelper();
                  List<int> rowsToDelete = new List<int>();
                  for (int i = 0; i < dataGridView1.Rows.Count; i++)
                  {
                     if (Convert.ToBoolean(dataGridView1["column1", i].Value))
                        {
                              rowsToDelete.Add(i);
                        }
                        foreach (int rowIndex in rowsToDelete)
                        {
                              dataGridView1.Rows.RemoveAt(rowIndex);
                        }
                       
                        dH.DeleteUser(i);
                  }
         }

      }
     
}
        




[\code]
AnswerRe: problem in DELETING rows from gridview and database table using a check box column and a DELETE button. Pin
Abhijit Jana24-Jul-09 6:49
professionalAbhijit Jana24-Jul-09 6:49 
AnswerRe: problem in DELETING rows from gridview and database table using a check box column and a DELETE button. Pin
SilimSayo24-Jul-09 7:27
SilimSayo24-Jul-09 7:27 
QuestionGetting Keystrokes even when the program is minimized Pin
Wamuti24-Jul-09 6:19
Wamuti24-Jul-09 6:19 
AnswerRe: Getting Keystrokes even when the program is minimized Pin
mypicturefaded24-Jul-09 6:22
mypicturefaded24-Jul-09 6:22 
AnswerRe: Getting Keystrokes even when the program is minimized Pin
DaveyM6924-Jul-09 6:23
professionalDaveyM6924-Jul-09 6:23 
Questionquery wizard Pin
mohammad alnoed24-Jul-09 5:55
mohammad alnoed24-Jul-09 5:55 
AnswerRe: query wizard Pin
Abhijit Jana24-Jul-09 6:26
professionalAbhijit Jana24-Jul-09 6:26 
GeneralRe: query wizard Pin
mohammad alnoed24-Jul-09 8:13
mohammad alnoed24-Jul-09 8:13 
GeneralRe: query wizard Pin
Abhijit Jana24-Jul-09 8:25
professionalAbhijit Jana24-Jul-09 8:25 
QuestionDoes anyone know any open source C# implementation of XAML Object Mapping Specification? Pin
Michael Sync24-Jul-09 5:35
Michael Sync24-Jul-09 5:35 
AnswerRe: Does anyone know any open source C# implementation of XAML Object Mapping Specification? Pin
BillWoodruff24-Jul-09 22:25
professionalBillWoodruff24-Jul-09 22:25 
GeneralRe: Does anyone know any open source C# implementation of XAML Object Mapping Specification? Pin
Michael Sync24-Jul-09 22:34
Michael Sync24-Jul-09 22:34 
QuestionProblem in datagridview datetimepicker column. Pin
priyamtheone24-Jul-09 5:24
priyamtheone24-Jul-09 5:24 
AnswerRe: Problem in datagridview datetimepicker column. Pin
Muhammad Mazhar24-Jul-09 5:47
Muhammad Mazhar24-Jul-09 5:47 
GeneralRe: Problem in datagridview datetimepicker column. Pin
priyamtheone24-Jul-09 6:55
priyamtheone24-Jul-09 6:55 
QuestionCreating a completely unclickable WebBrowser Pin
SimpleData24-Jul-09 3:29
SimpleData24-Jul-09 3:29 
AnswerRe: Creating a completely unclickable WebBrowser Pin
musefan24-Jul-09 3:33
musefan24-Jul-09 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.