OK, I'm confused how to write an INSERT/UPDATE for this simple app I'm developing locally to learn more about db interactions.
I have an "edit" page, which is populated from the db and lists up to 9 user links (user_id 2 in this case), so something like:
<input type="text" name="link1" value="www.yahoo.com">
<input type="text" name="...
The Data in my DataTable is like
ID ContactName1 Designation1 ContactName2 Designation2
1 A dummy B sam
The Table structure of my Table is
ID ContactName Designation
I am passing the values in the stored procedure as:
@ContactName1
@Designation1
@ContactName2
@Designation2
I want a single insert ...
When I do SELECT statements in PHP code I always select named columns, like:
SELECT id, name from users;
rather than using:
SELECT * from users;
This has the advantage of being more informative and readable, and also avoids problems later if new columns are added to the table.
What I'm wondering is, is it possible to use the same ...
I'm working on better understanding Linq-to-SQL before using on a real project, so I'm playing with it on a little side project. I've a table that I'm trying to update via DataContext.SubmitChanges() and it's failing due to primary key constraints.
I have no control over the table itself (I can't add an actual ID column), so instead ...
I have a stored procedure which does bulk insert on a SQL server 2005 database.
When I call this stored procedure from some SQL (passing in the name of a local format file and data file) it works fine. Every time.
However, when this same stored procedure gets called from C# .NET 3.5 code using SqlCommand.ExecuteNonQuery it works intermi...
I have this procedure which is inserting records from one table to another. the destination table is having an identity column called LeadId
Create Procedure prcInsertPrd
As
Begin
Begin Transaction
Declare @Identity int
Insert into Temp_ProductsArchive (column1,column2,column3) select
(column1,column2,colum...
This is probably a simple question. Let's say I have a small list with around 20-50 entries or so. Something like:
class Item
{
int ItemNumber;
int OrderNumber;
string Name;
}
stored in something like
List<Item>
This is stored either in a generic list or array in where the OrderNumber goes from 1, 2,3,4,....50. To makes thin...
Here is my sample data:
1;a;b;c;; 2;d;e;f;; 3;g;h;i;;
4;j;k;l;; 5;m;n;o;;
6;p;q;r;;
Here is my sample format file (BCP 9):
9.0
7
1 SQLCHAR 0 0 "" 0 x Latin1_General_CI_AS
2 SQLCHAR 0 0 ";" 2 i Latin1_General_CI_AS
3 SQLCHAR 0 0 ";" 3 s Latin1_General_CI_AS
4 SQLCHAR 0 0 ";" 4 t Latin1_General_CI_AS
5 SQLCHAR 0 0 ";" 5 u Latin1_Genera...
Hi!
I have a MySQL database which contains a table of users. The primary key of the table is 'userid', which is set to be an auto increment field.
What I'd like to do is when I insert a new user into the table is to use the same value that the auto increment is creating in the 'userid' field in a different field, 'default_assignment'....
hi,
I am a newbie to Database programming. After inserting a couple of rows into a DataSet object, I am trying to write back the updated DataSet to the Database but cannot figure out how to do it.
Can you give an example for the following please?
what SQL insert command to use if DataSet is already updated with new rows
Databinding e...
Hi,
I'm running into a problem where it is possible to insert a row into a table whithout specifically setting an INT NOT NULL column (defaults to 0 which is invalid for my purposes)
I create the table this way:
CREATE TABLE inventorycontrol (
ID INT NOT NULL UNIQUE AUTO_INCREMENT
,nodeID ...
This question is very similar to SQL Server 2005: T-SQL to temporarily disable a trigger
However I do not want to disable all triggers and not even for a batch of commands, but just for one single INSERT.
I have to deal with a shop system where the original author put some application logic into a trigger (bad idea!). That application ...
I have a table that normally, upon insert, the auto-key will increment. But, there are some instances when we want to set the ID (as would easily be done with "IDENTITY INSERT" in SQL).
Is there a way to accomplish this with LINQ to SQL?
Thanks,
...
Hi,
Im very new to SQL but need to write a query to do the following.
Using MS SQL Server 2005.
Profile DefinitioninProfile Definition
------ ------------------- ----------
ProfileID DefinitionID DefinitionID
ProfileType ProfileID ...
RESOLVED
From the developer: the problem was that a previous version of the code was still writing to the table which used manual ids instead of the auto increment. Note to self: always check for other possible locations where the table is written to.
We are getting duplicate keys in a table. They are not inserted at the same time (6 h...
I have a SQL database which i use to store some info and every record has a unique id generated by the database. MY program is written in flash and runs over the web, the program runs fine and it inserts records into the database and pulls the idnumber of the last record and displays it for user, my question is though how do i handle mul...
var newUser = new tblUser()
{
Email = strEmail,
Password = strPassword,
DateBirth = DateTime.Parse(strDateBirth),
};
db.tblUsers.InsertOnSubmit(newUser);
db.SubmitChanges();
I want to get the actual sql command text that linq generated.
...
I need a tool or method that allows the transfer of data and automatically updates the foreign keys at the destination table.
The SET IDENTITY_INSERT ON/OFF is not what I'm looking for.
Example:
table master (id int identity, name char)
table slave (id int identity, master_id int, name char)
I would like to create a script like thi...
Hi,
Currently I got this type of query generated by programmation (c#)
INSERT INTO TableName (Field1, Field2, Field3)
SELECT Field1, Field2, Field3 FROM TableName2
The problem is that the SELECT can have a result of many records (like a million), so it's take many times and the result is an connection timeout.
Also, if I separate al...
For Example, is there any way to do something like the following:
INSERT INTO table2 VALUES(SELECT x FROM table1 WHERE x > 5 LIMIT 4)
...