I need to copy data from a stringgrid into a MSSQL database table. The table had already been created using a sql statement. We need to copy 4 different table with many fields. Is there any very effective code to grab all data and save them into the database table. If not, I can code a loop sequence and insert the data row by row. But this seems to be very slow and not flexible.
Related
I want to create only certain columns on my "dbgrid" at run-time, and set them to
other table field(s) or same field . How do you do that :
illustration:
I have 3 Tables :
Student(IdStudent, NameStudent ...) ,
Module(idModul,NameModule...),
Notes(idNote,idStudent,idModul,Note).
I Want to insert All Notes in one Dbgrid and names of columns of DBgrid are names of Module Table. I have No idea?
Thanks.
You cannot do this with a dbgrid; dbgrids have only one datasource and a datasource has only one dataset. If you are using an SQL compliant database you should look into a join and/or crosstab to return a single dataset. (I think this is what MartynA is talking about) Or create a clientdataset at run-time and build it with the columns/data you want if you want data-aware. I would look into using a stringgrid, listview or treeview and build the whole thing by hand.
I've been facing this problem for the past few days. I am attempting to create a table view that is populated from a database query (seems simple enough). As I will be managing multiple tables, I have created a database helper class to fetch the data by using the sql queries. But it does not work consistently (or at all of late).
When I attempt to query a table, using one of the defined functions, the db return cursors with XX number of records, but null column data. In effect, multiple rows ( I see the row separators), but each row is blank.
Any suggestion or help is highly appreciated.
What is the most efficient way to duplicate a row in an Sqlite3 database exactly except with an updated PrimaryKey?
Use an insert .. select where both the insert and select reference the same relation. Then the entire operation will occur as a single statement within SQLite code itself which cannot be beaten for "efficiency".
It will be easier with an auto-PK (just don't select the PK column), although an appropriate natural key can be assigned as well if such can be derived.
See SQLite INSERT SELECT Query Results into Existing Table?
I have to tables in different databases (on the same server) that are identical. I need to transfer the data rows from the left database table to the right database table, but I only want to transfer the rows that aren't in the right database table already.
Is there a neat way of doing this?
Im using SQL Server 2008 R2
Assuming that you can uniquelly identify a row with column id:
insert into databasename..tablename
select * from datababasename2..tablename2
where id not in (select id from databasename..tablename)
I am using a stored procedure to return some rows from the database and its using an inner join query between 3 different tables.
But when I am filling the Dataset using SqlDataAdapter with this line of code:
adptr.fill(ds,"TBL_Employees")
it says the columns of the other tables do not belong to the table name I mentioned in fill method, that's right because the columns belong to another table in join query.
I want to know how to use the Fill method or what I am doing wrong.