I need to insert a data into a DB using query like this one:
INSERT INTO Table1
(aID)
VALUES
(select aID from Table2 where aID="aID"))
The problem is that if Table2 doesn’t have the aID I need to update it with it and extract the newly created ID. Is there a SQL command that automatically does it?
...
I am using SubSonic 3.0.0.3 along with the Linq T4 Templates. My ProjectRepository, for example, has the following two methods:
public int Add(Project item)
{
int result = 0;
ISqlQuery query = BuildInsertQuery(item);
if (query != null)
{
result = query.Execute();
}
return result;
}
private ISqlQuery Bui...
I have a DataTable which I want to save to a SQLite Database Table. Here is my dilemma, I don't know which way to go. At most the DataTable would contain 65,000 rows and probably 12 columns.
So, would it be faster to save the DataTable to a CSV file and then Bulk Insert it into SQLite (which I have no idea how to do) or would it be ...
Hi,
I'm trying to make an experimental web application which minimises redundant data.
I have three example tables set up like so:
Table one
ID | created_at (unix timestamp) | updated_at (unix timestamp)
Table two
ID | Foreign Key to table one | Title
Table three (pages)
ID | Foreign Keys to both table one and two | Content | Metadata...
I have create the following insert method by researching the internet but I know it needs some work since it quite bulky and unsightly. I have tested it and it works fairly well but I know it could work better. If possible could someone show me how to convert this method to use parameters and/or increase its efficency?
public static vo...
I want to print an entire directory of text files to a printer inserting the file name at the top of the first page of each file that is printed. A bash or openoffice script would serve me well. Thanks
...
I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1
I've prepared a simple example:
Showing all names
+--------------+-----------------------+
| user_id | name |
+--------------+-------------------...
I have four tables: Messages, MessageCategory, MessageStatus and MessageLevel.
MessageCategory, MessageStatus and MessageLevel all just have three fields: Identity (primary key), Code and Description. Messages refers to these three fields and has a few other data fields, including Identity (primary key) MessageText and Order. The Identi...
hi,
I am using flex builder 3 to insert into mysql database using php and everything is working perfectly in my localhost, the problem is when I deploy the project in the web server and run it, it connect to the database but i can't insert data ( it shows nothing when i insert data )
another stupid thing is in another piece of code for r...
I am trying to insert certain values into the table using SQL server 2005.
I have used textbox, label and listbox.
But by doing so, I have an error that states "Failed to convert parameter value from a ListItem to a String"
How do i solve this?
try
{
//Create an insert command
SqlCommand insertCmd = new...
I have table, which I am inserting records to another table.
What is the best way to mark record inserted, so it will not be attemted to being inserted again?
...
Hi friends,
I have an issue with js. I have form like below. Add button is adding li with input box and Remove button is removing... it is working very well. the issue is, it is creating the li after ul, out of ul :/ you can see it clearly at the screenshot below. any idea about solution? appreciate!!! thanks!!!
*
ps, how can I nam...
Why is this thing not working?
[Database(Name="Relationships_Test")]
[Table(Name = "Order")]
public class Order
{
[Column(Name="ID", IsPrimaryKey=true)]
public int ID { get; set; }
[Column(Name = "OrderDate")]
public DateTime OrderDate { get; set; }
public void Save()
{
DataContext dc = new DataContext(@"Data Source=.\sqlexpre...
For my application, I am trying to add entries without having a duplicate entry, and if there are a duplicate notify the user and have him try again. Using SQLite, which I know very very little about, I have tried these two ways and want to know which one is better, more efficient or a better way to develop it?
First way:
db.execSQL("I...
So I'm new to linq so be warned what I'm doing may be completely stupid!
I've got a table of caseStudies and a table of Services with a many to many relasionship
the case studies already exist and I'm trying to insert a service whilst linking some case studies that already exist to it. I was presuming something like this would work?
...
INSERT INTO UPLOAD_FILE_RECORD_FIELDS_DATA
select ?,?,?,?
union all
select ?,?,?,?
union all
select ?,?,?,?
I have to insert multiple records into one table.So i am using query as below.and setting parameter values. But i am getting error code 77.What is cause?
No of records to be inserted are approx 70000.So i am inserting 100 ...
Hello Im afraid about concurrency on partner application cause in the last days it was having troubles with CRUDS Operations, especially with inserts. So I ran SQL Profiler and note that his insert statement dont use transaction and also he is using :
INSERT INTO TABLEA VALUES ( (SELECT MAX(NUMBERFIELD) +1 FROM TABLEA), ....);
How avo...
Ok, let's say from start I'm not a SQL ninja. Anyway I'm using SQLite in a tiny project of mine. I've this test table:
CREATE TABLE [prova]
(
[id] INTEGER PRIMARY KEY UNIQUE,
[str] TEXT NOT NULL
)
and this query won't work:
insert into prova (id, str)
select null as id, "foo" as str
where not exists (select * from pr...
I'm using PostGis to store some spatial data. I used ActiveRecord to retrive data from db, and I used [Property (Formula = "asbinary(shape)")] on property where geometry was stored (property type was byte[]). However this doesn't work when inserting data. So I figured out to write custom insert (and update) queries to solve the problem. ...
Hi,
I am trying to insert a date value '2010-03-14 02:00:00 AM'(Day light saving start time for 2010 year) in a datetime field of a table in sql server 2005. The date is saved as '2010-03-14 03:00:00 AM' The server is installed in US(EST time zone).
Can anyone tell me the reason why the date is saving differently?
Thanks
Rupa
...