insert

sql server 2008 multiple inserts over 2 tables

I got the following trigger on my sql server 2008 database CREATE TRIGGER tr_check_stoelen ON Passenger AFTER INSERT, UPDATE AS BEGIN IF EXISTS( SELECT 1 FROM Passenger p INNER JOIN Inserted i on i.flight= p.flight WHERE p.flight= i.flightAND p.seat= i.seat ...

"Attach or Add an entity that is not new...loaded from another DataContext. This is not supported." Problem on insert of linker object.

Similar error as other questions, but not quite the same, I am not trying to attach anything. What I am trying to do is insert a new row into a linking table, specifically UserAccomplishment. Relations are set in LINQ to User and Accomplishment Tables. I have a generic insert function: Public Function insertRow(ByVal entity As Impleme...

Pasting textbox values to access database

Now i get the problem at the try statement ( int count =insert.......). The compailer says(when i push the buton on the form to save the values in textboxes) that it Failed to convert parameter value from a String to a Int32. code: private void button1_Click(object sender, EventArgs e) { string conString = "Provider=Mic...

In SQL Server, can multiple inserts be replaced with a single insert that takes an XML parameter?

So I have an existing ASP.NET solution that uses LINQ-to-SQL to insert data into SQL Server (5 tables, 110k records total). I had read in the past that XML could be passed as a parameter to SQL Server but my google searches turn up results that store the XML directly into a table. I would rather take that XML parameter and insert the n...

Creating an insert query (error of foreign key constrant)

I want to move data from one database's table to another database's table. It is giving me a foreign key error. Please tell me how I can insert all those data which is valid except those rows who don't have a foreign key. I am using SQL Server 2005 My query is : SET IDENTITY_INSERT City ON INSERT INTO City ([cityid],[city],[countr...

SQL Server insert with XML parameter - empty string not converting to null for numeric

I have a stored procedure that takes an XML parameter and inserts the "Entity" nodes as records into a table. This works fine unless one of the numeric fields has a value of empty string in the XML. Then it throws an "error converting data type nvarchar to numeric" error. Is there a way for me to tell SQL to convert empty string to nu...

Can't get SubSonic insert to work

I'm trying to insert a record into a table without using the SubSonic object in a VB.Net Windows app. (It will take too long to explain why.) Dim q As New SubSonic.Query("tablename") q.QueryType = SubSonic.QueryType.Insert q.AddUpdateSetting("Description", txtDescription.Text) q.Execute() This just updates all the rows in the table. I ...

insert Query is not executing, help me in tracking the problem

I tried the below query but it didnt executed giving error as : > #1064 - You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server > version for the right syntax to use > near ')' at line 1 . INSERT INTO `jos_menu` SET params = 'orderby= show_noauth= show_title= link_titles= show_intro= show_...

What could be the Consequence of inserting "id" in any autoincrementing 'id' containing table?

What could be the Consequence of inserting "id" in any autoincrementing 'id' containing table? If I have a Tabe in which I have configured the column "id" as the auto incrmented, But still I am using an INSERT query in which id is defined, like wise INSERT INTO XYZ (id) values ('26'); How does it going to effect the table and the proce...

How to insert an item into a key/value pair object?

Ok...here's a softball question... I just need to be able to insert a key/value pair into an object at a specific position. I'm currently working with a Hashtable which, of course, doesn't allow for this functionality. What would be the best approach? UPDATE: Also, I do need the ability to lookup by the key. For example...oversimplifi...

Vector insert() causes program to crash

This is the first part of a function I have that's causing my program to crash: vector<Student> sortGPA(vector<Student> student) { vector<Student> sorted; Student test = student[0]; cout << "here\n"; sorted.insert(student.begin(), student[0]); cout << "it failed.\n"; ... It crashes right at the sorted part...

Is there a web site where I can paste a SQL Insert statement and have it break it out by column?

I've been working on an application that has no discernable data access layer, so all the SQL statements are just built up as strings and executed. I'm constantly confronted by very long INSERT statements where I'm trying to figure out what value in the VALUES list matches up with what column in the column name list. I was about to cre...

what is wrong with this insert method in asp.net mvc?

My controller calls a repository class method on insert, [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude = "Id")]FormCollection collection) { try { MaterialsObj materialsObj = new MaterialsObj(); materialsObj.Mat_Name = collection["Mat_Name"]...

asp.net mvc insert doesnt seem to work for me....

My controller's call to repository insert method all the values are passed but it doesn't get inserted in my table.. My controller method, [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude = "Id")]FormCollection collection) { try { MaterialsObj materialsObj = ...

Insert a record with a value partly from another table

I have two tables, Proteins and Species. Protein has Species.Id as foreign key constraint. When I insert the data, I know the name of the species that protein belongs to, but not the Id. So I do the following: PreparedStatement query = connection.prepareStatement( "SELECT Id FROM Species WHERE ShortName = ?"); query.setS...

How do I insert data into a object relational table with multiple ref in the schema.

I have a table with a schema of Table(number, ref, ref, varchar2, varchar2,...). How would I insert a row of data into this table? When I do: insert into table values (1, select ref(p), ref(d), '239 F.3d 1343', '35 USC § 283', ... from plaintiff p, defendant d where p.name='name1' and d.name='name2'); I get ...

Generating incremental numeric column values during INSERT SELECT statement

I need to copy some data from one table to another in Oracle, while generating incremental values for a numeric column in the new table. This is a once-only exercise with a trivial number of rows (100). I have an adequate solution to this problem but I'm curious to know if there is a more elegant way. I'm doing it with a temporary seq...

SqlCommand Timeout Expired on Simple Insert Statement

I am trying to execute a simple insert statment into a table with a large amount of rows...one of the columns in the table is of Xml data type sqlCmd.CommandText = String.Format( @"INSERT INTO Responses (CorrelationId, LoanNumber,ClientId, Received, Source, ResponseXml, Success, ErrorMessage) VALUES ('{0}', '{1}', '{2}...

Increment a database field by 1

With MySQL, if I have a field, of say logins, how would I go about updating that field by 1 within a sql command? I'm trying to create an INSERT query, that creates firstName, lastName and logins. However if the combination of firstName and lastName already exists, increment the logins by 1. so the table might look like this.. firstN...

MySQL Workbench 5.2. Load INSERTs from a file

How can I load INSERTs from a file in MySQL Workbench 5.2? I have tutorial for 5.0, but for 5.2 it is not working ...