insert

[EF 4 POCO] Problem with INSERT...

Hi all, I'm so frustrated because of this problem, you have no idea... I have 2 classes: Post and Comment. I use EF 4 POCO support, I don't have foreign key columns in my .edmx model (Comment class doesn't have PostID property, but has Post property) class Comment { public Post post { get; set; } // ... } class Post { publ...

Insert statement with where clause.

I had a table with unique Date_t1 date type field, but in Table description field is not mentioned as unique, now while inserting new row i need to validate if date exist or not, If already exist i should not allow to make changes on that row, neither a new row needs to be created, Any idea how to resolve this problem in efficient way, ...

Why isn't "String or Binary data would be truncated" a more descriptive error?

To start: I understand what this error means - I'm not attempting to resolve an instance of it. This error is notoriously difficult to troubleshoot, because if you get it inserting a million rows into a table 100 columns wide, there's virtually no way to determine what column of what row is causing the error - you have to modify your pr...

How do I INSERT INTO from one mysql table into another table and set the value of one column?

Hi, I need to insert data from table1 into table2. However, I would like to set the myYear column in table2 to 2010. But, there isn't a myYear Column in table1. So, my basic insert looks like: INSERT INTO `table2` ( place, event ) SELECT place, event FROM table1 Roughly, I'd like to do something like the following: INSERT INTO `t...

UITableView rows load asynchronously

On launch of app, i want to show 10 rows, at the bottom "Load 15 more", on click on "Load 15 more" the next 15 rows should add to the bottom of the table and again show "Load 15 more", until no rows found. note: I am using php to load table data as an xml feed. If anyone has any tutorial/sample code pl send me the link ...

MySQL INSERT Query

Hi, I need a query to perform the following: find the countryID where country = 'UK' from table Countries then use the found value in INSERT into towns (id, country_fk, name) values (1, <value_found>, 'London'). is this possible? UPDATE I need to store the value once so that I can use it in multiple INSERTS (about 100) ...

Why use bin2hex when inserting binary data from PHP into MySQL?

I heard a rumor that when inserting binary data (files and such) into MySQL, you should use the bin2hex() function and send it as a HEX-coded value, rather than just use mysql_real_escape_string on the binary string and use that. // That you should do $hex = bin2hex($raw_bin); $sql = "INSERT INTO `table`(`file`) VALUES (X'{$hex}')"; //...

Python mysql check for duplicate before insert

Hi here is the table CREATE TABLE IF NOT EXISTS kompas_url ( id BIGINT(20) NOT NULL AUTO_INCREMENT, url VARCHAR(1000), created_date datetime, modified_date datetime, PRIMARY KEY(id) ) I am trying to do INSERT to kompas_url table only if url is not exist yet any idea? thanks ...

Increment non unique field during SQL insert

I'm not sure how to word this cause I am a little confused at the moment, so bare with me while I attempt to explain, I have a table with the following fields: OrderLineID, OrderID, OrderLine, and a few other unimportant ones. OrderLineID is the primary key and is always unique(which isn't a problem), OrderID is a foreign key that isn...

mysql insert and buffers, is this possible

how is this possible first i do insert into table2 select * from table1 where table1.id=1 ( 50k records should be moved 6 indexes has to be updated ) second delete from table1 where id=1 ( 50k records are removed ) How is it possible that only 45k of records are moved? Im scratching my head over this and cant find a right answer Is...

updating batches of data

I am using GridView in asp .net and editing data with edit command field property (as we know after updating the edited row, we automatically update the database), and I want to use transactions (with begin to commit statement - including rollback) to commit this update query in database, after clicking in some button (after some events ...

How can I programatically add an item to this dialog?

When I insert an SD card, Windows XP/Vista/7 presents a dialog asking the user what they want to do with the contents. How can I add an item to this list for only certain types of data? (Like photos, music, etc.) ...

SQL: How do I INSERT primary key values from two tables INTO a master table.

Hello, I would appreciate some help with an SQL statement I really can't get my head around. What I want to do is fairly simple, I need to take the values from two different tables and copy them into an master table when a new row is inserted into one of the two tables. The problem is perhaps best explained like this: I have three ta...

How to insert Search Query into MYSQL - Check for Double Words

Hi, what is the best method to insert a search query into MySql and check for double words? (for showing up the last searches and a collection of searches) maybe something like this: < ?php /*------------------------------ Read and save the search query -------------------------------*/ $querystat = mysql_real_escape_string($_GET['q'...

Update multiple rows with known keys without inserting new rows if nonexistent keys are found

Hello, Let's imagine that we have table items... table: items item_id INT PRIMARY AUTO_INCREMENT title VARCHAR(255) views INT Let's imagine that it is filled with something like (1, item-1, 10), (2, item-2, 10), (3, item-3, 15) I want to make multi update view for this items from data taken from this array [item_id] => [views] '1...

Extending DataList to accept a new InsertCommand from LinkButtons

I'm trying to subclass DataList to accept a new Command from embedded LinkButtons. Here's my abstract class: public abstract class BaseFieldGroup : DataList { public const string InsertCommandName = "Insert"; public event DataListCommandEventHandler InsertCommand { add { base.Events.AddHandler(Ev...

Check value at insert

Hello, i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table: Tag Columns: TagID, Title Table: ItemTag Columns: ItemID, TagID In the Item Table is a Field with NoChange, if this field = true no Tag is allowed to insert a ItemTag value with this ItemID. How can i check this in the insert? For U...

PHP - How to insert special characters into a database?

Hello. Can anyone tell me how to insert special characters into a MySQL database? I've made a PHP script which is meant to insert some words into a database, although if the word contains a ' then it wont be inserted. I can insert the special characters fine when using PHPmyAdmin, but it just doesn't work when inserting them via PHP. Cou...

Inserting nil Values into Sqlite Database?

I am working on an iPhone App where I am pulling data from an XML file and inserting it into a sqlite database located in the App. I am able to successfully do this process, but it appears that if I try to sqlite3_bind_text with a NSString that has a value of "nil", the App quickly dies. This is an example of code that fails: (modified...

Bulk Copy from one server to another

I've one situation where I need to copy part of the data from one server to another. The table schema are exactly same. I need to move partial data from the source, which may or may not be available in the destination table. The solution I'm thinking is, use bcp to export data to a text(or .dat) file and then take that file to the destin...