i have a query: select id, name from Dictionary
field "id" is guid (so not null, and not identity)
i show only "name" in the dataGrid
how to set new id when i insert a new record?
currently VS wizard created insert command for me:
INSERT INTO Dictionary (id, name) VALUES (@id, @name );
SELECT id, name FROM Dictionary WHERE (id = @id)
it is not working "Column "id" doesn't allow nulls. Do you want to correct
the value?"
thank you 10 2950
Set the 'id' column in your DataTable to a value. Like Guid.NewGuid().
Or give the column a default of 'newid()' in the database
"Serdge Kooleman" <Su***@web.de > wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. i have a query: select id, name from Dictionary
field "id" is guid (so not null, and not identity)
i show only "name" in the dataGrid
how to set new id when i insert a new record?
currently VS wizard created insert command for me:
INSERT INTO Dictionary (id, name) VALUES (@id, @name ); SELECT id, name FROM Dictionary WHERE (id = @id)
it is not working "Column "id" doesn't allow nulls. Do you want to correct the value?"
thank you
Automatically generated updated/insert queries are based on the parameters
of the SELECT query. Since you are selecting both ID and name, the same
parameters end up in the generated queries. However, if ID is the primary
key (and you configured it to auto-increment in your DB), you don't need to
provide it as part of the insert query. A new ID will be generated
automatically when you insert a new record.
--
Kai Brinkmann [Microsoft]
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Serdge Kooleman" <Su***@web.de > wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. i have a query: select id, name from Dictionary
field "id" is guid (so not null, and not identity)
i show only "name" in the dataGrid
how to set new id when i insert a new record?
currently VS wizard created insert command for me:
INSERT INTO Dictionary (id, name) VALUES (@id, @name ); SELECT id, name FROM Dictionary WHERE (id = @id)
it is not working "Column "id" doesn't allow nulls. Do you want to correct the value?"
thank you
i mentioned that my id is not auto-increment. who use it?!
i have guid-based id.
how to update id in my case? Automatically generated updated/insert queries are based on the parameters of the SELECT query. Since you are selecting both ID and name, the same parameters end up in the generated queries. However, if ID is the primary key (and you configured it to auto-increment in your DB), you don't need to provide it as part of the insert query. A new ID will be generated automatically when you insert a new record. -- Kai Brinkmann [Microsoft]
> Set the 'id' column in your DataTable to a value. Like Guid.NewGuid().
how to update it? (i have DataSet)
do we have an event like "before insert" ? Or give the column a default of 'newid()' in the database
i tried to do it. the same result.
If the ID is a required value, you will have to figure out a way to create a
new ID before executing the INSERT query. Look at Marina's suggestion.
--
Kai Brinkmann [Microsoft]
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Serdge Kooleman" <Su***@web.de > wrote in message
news:OZ******** ******@TK2MSFTN GP14.phx.gbl... i mentioned that my id is not auto-increment. who use it?! i have guid-based id. how to update id in my case?
Automatically generated updated/insert queries are based on the parameters of the SELECT query. Since you are selecting both ID and name, the same parameters end up in the generated queries. However, if ID is the primary key (and you configured it to auto-increment in your DB), you don't need to provide it as part of the insert query. A new ID will be generated automatically when you insert a new record. -- Kai Brinkmann [Microsoft]
Kai,
seems to me that u do not understand what i need.
i do not want to use newid() function in sql.
i want to generate new guid in C# ( System.Guid.New Guid() )
could you give a code example? what event should i use?
where i should write: parameter['ID'] = 'value' ?
where ?
what event or something like this?
thank you If the ID is a required value, you will have to figure out a way to create a new ID before executing the INSERT query. Look at Marina's suggestion.
i know how to generate new ID.
in what place shoud i add this value to parameter?
thank you
forget to say: i use WinForms
At some point you are adding a row to this datatable. So where ever you add
the row, that's where you set the column value.
"Serdge Kooleman" <Su***@web.de > wrote in message
news:ex******** ******@TK2MSFTN GP14.phx.gbl... Set the 'id' column in your DataTable to a value. Like Guid.NewGuid(). how to update it? (i have DataSet) do we have an event like "before insert" ?
Or give the column a default of 'newid()' in the database i tried to do it. the same result.
> At some point you are adding a row to this datatable. So where ever you add the row, that's where you set the column value.
Marina, i add row in DataGrid (winforms).
And i exactly need an advise: where to put code
parameter[id] = "something"
where? i do not see any places for that.... no any "before update event" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: adove |
last post by:
I am having problems with the following code. I am trying to update my db table Categories in Northwind. I have borrowed this code from www.dotnetjohn.com/articles/articleid27.aspx Although it works on dotnetjohn website, I cannot replicate the code successfully. I have a datagrid filled with data and two textboxes with an “Insert” button....
|
by: randy |
last post by:
Hello all,
I have a DataTable which I am building column by column and adding rows
after each new column. The DataTable columns match the columns in my
database table. I'm building the DataTable first and I then want to roll
through the DataTable while in memory checking for errors and then commit
the rows to my database table (btw this...
|
by: Pesko S |
last post by:
Hi,
Could anybody just point me in a direction where I can find information
on how the heck I can update a database with relational data from an XML
file.
I use stored procedures to insert the data. And I am NOT storing the xml
in the database. I want to map the xml elements to the database columns.
I am about to start peeling my skin...
|
by: Serdge Kooleman |
last post by:
i have a query: select id, name from Dictionary
field "id" is uniqueidentifier (primary key id is not null, and not identity
!)
i show only "name" in the dataGrid
how to set up new id when i insert a new record? from the c#? from the sql?
INSERT INTO Dictionary (id, name) VALUES (@id, @name );
Always i'm getting message: "Column "id"...
|
by: Serdge Kooleman |
last post by:
i have a query: select id, name from Dictionary
field "id" is uniqueidentifier (primary key id is not null, and not identity
!)
i show only "name" in the dataGrid
how to set up new id when i insert a new record? from the c#? from the sql?
INSERT INTO Dictionary (id, name) VALUES (@id, @name );
Always i'm getting message: "Column "id"...
| |
by: Ed |
last post by:
Hi,
I want to load data to a table in Sql Server from a
dataset table in my vb.net app using a dataAdapter. I
know how to do this as follows (my question is to see if I
can reduce the amount of code below):
....
Dim DA As SqlDataAdapter = New SqlDataAdapter
Dim Parm As New SqlParameter
....
|
by: mcasey0827 |
last post by:
I'm writing a little app to get data from a CSV file generated everyday by a vendor and insert it into a Table in our SQL Server database. I can get the data fine, and I can easily merge it with another dataset I pull from the existing table (which is exactly the same except for an Identity Column as PK).
When I call SqlDataAdapter.Update, ...
|
by: niccolem |
last post by:
HI:
Can someone tell me HOW to insert a automatic number after my user inserts new data from text boxes into the dataset. I keep getting this error:
Cannot insert the value NULL into column 'id', table; column does not allow nulls. INSERT fails. (ID IS MY KEY)
I can update & delete fine, but when I try to insert, I cannot figure out how to...
|
by: anu b |
last post by:
Hi
I need to use Clr trigger for insert command
My code is as below
I am using SQL server 2005 and VS 2008.... but after running this
code
i didnt get the result as i expexted it shows the result as no row
is
effected ...Please help me guys
using System;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |