Questions tagged [sqlcommandbuilder]

Automatically generates single-table commands that are used to reconcile changes made to a DataSet with the associated SQL Server database.

Automatically generates single-table commands that are used to reconcile changes made to a DataSet with the associated SQL Server database.

71 questions
0
votes
0 answers

Define an SQL datetime Parameter as nullable

In my stored procedure I am trying to define this datetime parameter as a nullable variable. @StartDate datetime = null When I try and dynamically retrieve the parameters in code. SqlCommandBuilder.DeriveParameters(sqlCommand); int parameterId =…
Hammeric
  • 1
  • 1
0
votes
3 answers

dataset update fails when inserting new row

I am inserting a new row into a dataset dsStaff1 via DataAdapter1.Update() method. I am getting the following error: Cannot insert the value NULL into column 'Enabled', table 'dbo.tblStaff'; column does not allow nulls. INSERT fails. The…
hrishi
  • 83
  • 1
  • 9
0
votes
1 answer

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. DB concurrencyException was unhandled

i have defined 2 datasets and 2 dataAdapters( one for each of the datasets ) . after creating, for each of the 2 dataAdapters i define a SqlCommandBuilder. All is well till here. I can add, modify, erase very ok from the database using…
Alex
  • 10,869
  • 28
  • 93
  • 165
0
votes
1 answer

How to inherit parameter size from original table definition?

Using SqlDataAdapter and SqlCommandBuilder the created update statements for sql server are inefficient as explained below. Here is sample code for reproduction: Sql Server: Create database TestDB; GO USE [TestDB] CREATE TABLE [dbo].[test]( [i]…
0
votes
0 answers

Why I need the SqlCommandBuilder to update a table in Database?

I watched a video tutorial and reprogrammed the same code. I have noticed that a didn´t understand, why I have to use the SqlCommandBuilder for updating a table. SqlDataAdapter sda; SqlCommandBuilder scb; DataTable dt; private void…
0
votes
0 answers

Could I use stored procedure with command builder and datagridview?

SqlConnection con = new SqlConnection("Data source=.;Database=training; integrated security =true"); DataSet ds = new DataSet(); SqlDataAdapter da; private void Form1_Load(object sender, EventArgs e) { …
0
votes
2 answers

Cannot Add a Row Using SQL and CommandBuilder C#

I'm doing this exactly (see Using SqlDataAdapter to insert a row) but it doesn't give me the .ADD method Here is my code: var sqlQuery = "select * from CT_DETIMP where 0 = 1"; SqlDataAdapter tableAdapter = new SqlDataAdapter(sqlQuery,…
Missy
  • 1,286
  • 23
  • 52
0
votes
1 answer

update a dataset corresponding to a database from it's datagridview

There is a datagridview corresponding to a table of some database. This database has an (auto-incrimenting) identity column named "id". This column is the primary key, too. Right now, a user just sees a blank and empty datgridview. He/she can modify…
samsam114
  • 987
  • 2
  • 8
  • 20
0
votes
0 answers

How to write manual SQL command in VB.Net to Update from DataGridView without using CommandBuilder

I am creating a windows application using VB.Net & SQLite Database. In one of my win form i used to retrieve data from two tables (ImpShpHeader, ImpShpDetail) by separate SQL command under a single event. ImpShpHeader Data retrieving in textboxes…
Muhammad Tarique
  • 1,407
  • 1
  • 13
  • 17
0
votes
1 answer

SQLCommandBuilder - UPDATE from DataTable only "Appends" Database Table

I am trying to UPDATE database table rows using SQLCommandBuilder with datatable rows using the following test code. One table with a primary key column and one datatable to keep it simple. Using the following code, the dbo.Dogs2 table is…
0
votes
1 answer

SqlCommandBuilder With Convert Statement

I have an application that's built in .NET language. In this application we mainly read/write to the database (SQL Server 2005). Sometimes (for a single input) I just use the SQL query, for example: commandText = "INSERT INTO Test_Table (Number)…
Michiel281
  • 55
  • 1
  • 4
0
votes
1 answer

DataTable.Update Fails and Throws DBConcurrencyException

I'm trying to take advantage of the DataTable.Update method to update a SQL data source. Below is the code for the method that performs the update. string connString = "SQL connection string...this works."; string sqlSelect = "SELECT Payment,…
gh0st
  • 1,653
  • 3
  • 27
  • 59
0
votes
3 answers

Select Command initialized Error

Question I've been struggling with this for a while now. I have the error below although I thought I had initialized the select command? The dataadapter.selectcommand.connection property needs to be initialized I know I am not getting this error…
Dan Cundy
  • 2,649
  • 2
  • 38
  • 65
0
votes
1 answer

How to override values in merging DataTables using .Merge() method?

Is there a way to override values in merging DataTables using .Merge() method? For example if I have two DataTables with the same schematics. Both have two Columns: Names | Enabled; DataTable1 first row entries are: Peter Punani | true; DataTable2…
hYde
  • 33
  • 1
  • 9
0
votes
1 answer

CommandBuilder and SqlTransaction to insert/update a row

I can get this to work, but I feel as though I'm not doing it properly. The first time this runs, it works as intended, and a new row is inserted where "thisField" contains "doesntExist" However, if I run it a subsequent time, I get a run-time error…
KarlHungus
  • 237
  • 4
  • 13