insert

php array insert new item in any position

how can i add new item to array? for example in the middle of array? ...

sql ce escape '(single quote) C#

I am writing some code to store names in a database. I limit the names to only certain characters, but last names are a challenge. Since some people have single quotes in their name (example O'Brian) I need to allow this. So I wrote a regex replace to replace the ' with a \' which I assumed should make the ' a literal. It works as far...

PHP."INSERT INTO" run twice via PHP mysqli_query!

for($j = 0 ; $j < 87; $j++){ echo $j.'<br/>'; $unique = mt_rand(0,100000000); $insert_data = 'INSERT INTO uniques(uniq) VALUES ("'.$unique.'")'; mysqli_query($conn , $insert_data); echo $unique.'<br />'; } I just want to insert random number into table uniques. But something wrong with above code.It w...

sqldatasource insert return identity value

Im using SqlDataSource sds = new SqlDataSource(); in code behind and inserting using sds.Insert(); Please tell me how to get inserted record primary key value? Please note im not using stored procedure. ...

optimize mysql database - myISAM db

i have two question about msyql performance with my db using MyISAM engine : 1) what is smart way to solve the problem that when INSERT or UPDATE some rows in one table, many SELECT queries be hang on. 2) Is this easy to change from MyISAM to InnoDB with database is current running? 3) Why myISAM is still be default option of mySQL w...

INSERT query is not letting me post data to database

I'm trying to implement a comment.php script that takes the data from a html textfield and save it to a database in phpmyadmin. I implemented registration.php, which is longer and it inserts new users flawlessly. Now the comment.php, which is simpler is not adding anything to a comments table. Here's the code for comment.php: <?php ...

MySQL Issue Copying from one table into another directly

I use the following code to copy from one table directly into another: $transfer = $db->exec("INSERT INTO table2 SELECT * FROM table1 WHERE groupname = '$gname'"); The issue I have, however, is the ID field of both tables do not necessarily match (both auto-increment) and at times this may mean one temporary's tables ID# is higher than...

What Do PostgreSQL INSERT confirmation params mean?

I am new to PostgreSQL and I searched high and low but cannot find an answer to this question in my LiveCode Server app I'm getting a dberr returned on insertion but no explicit error code. I went on terminal and did the insertion by hand as user Postgres %My_Dbase=# INSERT INTO new-table (first_name, last_name, anonymous) VALUES ('ba...

LAST_INSERT_ID() MySQL

I have a MySQL question that I think must be quite easy. I need to return the LAST INSERTED ID from table1 when I run the following MySql query: INSERT INTO table1 (title,userid) VALUES ('test',1); INSERT INTO table2 (parentid,otherid,userid) VALUES (LAST_INSERT_ID(),4,1); SELECT LAST_INSERT_ID(); As you can understand the current co...

SELECT INTO a table variable in T-SQL

Got a complex SELECT query, from which I would like to insert all rows into a table variable, but T-SQL doesn't allow it. Along the same lines, you cannot use a table variable with SELECT INTO or INSERT EXEC queries. http://odetocode.com/Articles/365.aspx Short example: declare @userData TABLE( name varchar(30) NOT NULL, oldloca...

Detailsview Keeping items after inserting, not able to increment?

I have a checkbox that allows users to keep the input in a detailsview to help if they are inputting many similair items. I'd like one field to increment, but it won't take. I've even tried putting it in a hidden field. Incrementing field: Protected Sub DetailsView3_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebContr...

user default column value in INSERT stored procedure

From my ASP.NET application I am calling an INSERT stored procedure, there is a default value for one of the columns in the table that the INSERT procedure places the data into. How do I specify that I want the default value to be used instead? (Or do I have to specify the actual default value in my parameters) SITUATIONAL TABLE: Colum...

Strange MySQL Issues

So I setup a table using mysql query browser, and now i'm trying to fill it up. But no matter what I do, it says "created account succesfully", but nothing ever gets added to the database! The code I have is below: ` if($connection) { $out = "<p>Please wait while we process ...

How to Insert row into SQL database with IDENTITY_INSERT set to OFF using WCF services?

An SQL table has auto increment property set for the primary key AnnotationID of INT type. The Silverlight application WCF service code: public void InsertImageAnnotation(int imageId, string imagePath) { DataClassDataContext db = new DataClassDataContext(); ImageAnnotation row = new ImageAnnotation(); r...

SQL: is it possible to combine an INSERT and SELECT statement into one

I want to add a row using SQLs INSERT statement. Is it possible that as part of this statement I can somehow get the value of the column userId which I don't update but is the AUTO_INCREMENT primary key. I need this value to update another table, however I can't follow the Insert statement immediately with a SELECT statement as there is ...

Insert Mysql with PHP - problem with foreign key insert

Hi, I have 4 Tables [project_select] UserID (fk) | project_id (fk) | project_category_id (fk) [project_category] project_category_id | category [projects] project_id | projectname [project_user] UserID | Name How can I insert Data with php in the tables project_category, projects and project_user, to get automatically the values in...

Updating Table when inserting/deleting rows.

Hi, I have a singleton class which is used to display data across various views. There is one TableView which is used to delete/insert rows. I have a button that changes between Edit/Done to allow Editing. 'streams is a variable within the Singleton class' - (void)setEditing:(BOOL)flag animated:(BOOL)animated{ int count =...

Getting an Error on inserting data when using Linked Server Queries

UPDATE : The issue was col1 was hiereachyid type and even a select didnt work for it. Hi all, I am getting this error - Objects exposing columns with CLR types are not allowed in distributed queries. Please use a pass-through query to access remote object '"RemoteDb"."dbo"."RemoteTable"'. I have already setup the linked server ...

sql server merge with multiple insert when not matched

Hi. I'm using MERGE in my query and i'm making INSERT on clause WHEN NOT MATCHED THEN, but then i would like to get the inserted row identity and make another INSERT to some other table. Query for now is: ALTER PROCEDURE [dbo].[BulkMergeOffers] @data ImportDataType READONLY AS SET NOCOUNT ON; DECLARE @cid int = 0 MERGE dbo.oferta AS ta...

insert XmlDocument into a XmlDocument node

I created a basic XmlDocument with one node: XmlDocument bigDoc = new XmlDocument(); bigDoc.LoadXml("<Request></Request>"); and I'm getting another XmlDocument that I want to insert inside <Request> node. It doesn't work for me: XmlNode requestNode = bigDoc.FirstChild; requestNode.AppendChild(anotherXMLDocument); It thorows an e...