How To Insert List of Record To the Database Using Linq

Good day every one, Please i need little help, I have a list of record like this
lblID.Text = string.Join("<br/>", numbers);
gives the Numbers below...
6131
5241
3978
6824
3842//To Save to the database
int pin = int.parse(lblID.Text);
Now i want to insert those Numbers to the database
Persons ps = new Persons();
ps.Number = pin;
cdc.Persons.AddObject(ps);
cdc.SaveChanges();
it throws up error...
what i want to achieve on button insert
all Numbers will be inserted but before inserting the number it will check if those numbers exist first on the database
it should be like this on the database
ID Number
1 6131
2 5241
3 3978
4 6824
5 3842
thanks.. I do appreciate your time and effort

Hello,
>>Now i want to insert those Numbers to the database
For inserting a list of items to database, a loop statement is needed. I do not how you get these numbers, I assume they are stored in a collection and you could check below demo sample to insert these numbers and I assume your person table is identified:
using (DFDBEntities db = new DFDBEntities())
List<int> numbers = new List<int>() { 6131, 5241, 3978, 6824, 3842 };
for (int i = 0; i < numbers.Count; i++)
int number = numbers[i];
//Check if the local and database already contains this number
bool isRecordExist = db.Tables.Any(t => t.Number == number) || db.Tables.Local.Any(t => t.Number == number);
if (!isRecordExist)
Table t = new Table();
t.Number = number;
db.Tables.Add(t);
db.SaveChanges();
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to get first 10 records from the database using JSP

    i want ot get first 10 records from the database and then after clicking the next button in the page,it must show the next precceding 10 records from the database.i am getting the first 10 records .but how to post to the same page to get another preceeding 10 record.

    Search the forums - this has been asked a lot. I usually recommend experimenting with tops and order bys until you're satisfied.
    Kind regards,
      Levi

  • How to speed insert my 1000000 records into the database?

    my code like:
    <cfloop from="1" to="#inserteddb.getrecordcount()#"
    index="x">
    <!----
    Here make the InsertFieldList and InsertValueList
    --->
    <cfquery datasource="#cfdsn#" name="insertdata">
    insert into inputtest (#InsertFieldList#)
    values (
    <cfqueryparam value="#InsertValueList#"
    cfsqltype="cf_sql_varchar" list="yes">
    </cfquery>
    </cfloop>
    The test inserts 100,000 records, has spend I 30 minutes
    time,but I have 1,000,000 record to insert , is there any way to
    enhance the insertion speed?
    Thanks a lot.

    By removing ColdFusion from the process as much as possible.
    Where is the 'insertedDB' data coming from? It looks to be a
    record set?
    Are you moving data from one data source to another? If so,
    some DBMS
    have the ability to insert an entire record set in one step.
    I do not
    have the exact syntax at my finger tips, but I have done
    something like
    this in the past with Oracle. INSERT INTO aTable SELECT FROM
    bTable.
    Are you building a record set from a text file such as CSV?
    If so, many
    DBMS have the ability to do 'bulk' inserts from such text
    files and CF
    does not even need to be involved.
    As you can see, knowing exactly what are you working with
    will help us
    provide suggestions an how to improve your process.

  • Insert a new record in the database table in between the records.

    i va a database table which ve 100 records. but i want to insert my new record  as 50th record. how i want to  proceed?
    thanks ,
    velu.

    V,
    This is an odd request.  Why?
    Ignoring that, you can ATTEMPT to insert into the 50th position IF:
    1) The DB table has just had the primary key index re-built/re-shuffled to GUARANTEE that it IS in primary key order
    2) And the primary key of the new record is built so that it follows the 49th record
    Regardless, once this table has activity against it, its sort order can/will get out of promary key order (with adds/changes/deletes). 
    But when you select data from it, you can use ORDER BY or an ABAP SORT to organzie the date as needed.
    Again... not sure WHY you need a record in a particular physical position... who cares... it is a relational DB.

  • LSO - How to create classroom training records in the past using LSO trans

    Hello,
    we are managing classroom training outside SAP but we want to maintain retrospectively the information in LSO in order for employees to see in the Portal as Completed Training.
    When using the LSO transaction (e.g. LSO_PV08) to book the participant the system uses the current date. And this date is not modifiable using PP01 for the system does not allow direct maintenance of "E A025 to P" relationship.
    Is there a way to "control" the booking date?
    Thanks
    Kind regards,
    Olivier

    Hello Deepak,
    thanks for your help.
    The issue is that changing T777E is not enough to be able to maintain the fields value. Indeed when I select the relationship through PP01, then additional data, the screen I end up with, does not allow maintenance and rather display a message "Protected tab titles are not supported (tab TABSTR_025 title TAB1)"
    Anyway what I would like to know if there is a way in LSO, when using standard functionalities such as "Booking a course" (with LSO_PV00 for example) to control the booking course date (for my system it is always the system date which is not acceptable if I want to create historical data [my classroom training took place last month so I want my training records and more specifically the "Booking Date" to be last month ]
    Regards,
    Olivier

  • How to change COMPATIBLE parameter while creating the database using DBCA

    I have installed 10.2.01.0 on centos 4.7
    Now i want to create database with COMAPTIBLE parameter 9.2.0.1
    I m trying to create database through DBCA, changed the initialization parameter COMAPTIBLE to 9.2.0.1.
    But gives me error
    ORA-19583: conversation termintated to error
    ORA-19870: error reading backup peice /opt/oracle/assistants/dbca/templates/Seed_Database.dfb
    ORA-00600: internal error code,arguments: [krbrckhr_compressed],[opt/oracle/assistants/dbca/templates/Seed_Database.dfb],[29],[30],[11420],[],[],[]
    ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5149
    ORA-06512: at line 16
    if i dont change the value of COMPATIBLE parameter then its running perfactly...
    But i have to set compatible parameter as 9.2.0.1....
    Can anybody tell me how to create database using 10g R2- 10.2.0.1.0 with compatible parameter 9.2.0.1

    Thank you for your response.
    I have tried that opting.
    After creating the database with COMAPTIBLE parameter 10.2.0.1.0 changed that parameter in init.ora file to 9.2.0 and start the database.
    But at that time getting
    ORA-00201: contorl file version 10.2.01.0 incompatible with ORACLE version 9.2.0.0
    ORA-00202: control file '/opt/oracle/oradata/ORCL/control01.ctl'

  • How to remove only one row from the database using labview6.1

    using labview 6.1 I create a table with various rows and columns and store bulk of data's in them.,, what procedure should I follow to remove only one paticular row from the database? Help me out with an example please,,
    Thanking you in advance!

    Hi,
    If you have the database toolkit you can delete a row using just a SQL Query to "DB Tools Execute Query.VI"
    Example:
    DELETE FROM Table name Where SerialNum='Value' And Date='Value' And Time='Value'
    See also attached VI
    Best Regards
    Johan
    Attachments:
    Delete_a_row_in_a_database_table.vi ‏48 KB

  • How to view images which resides in the database using JFrame.

    Hello defts,
    Im developing an application using swings. I need to display a image in a JFrame during an button click event. where that image resides in the database.

    the image shouldn't be in the db, just the path to the image location.
    so, open the db, get the location, close the db, get the image from the location,
    then either add the image to the frame via a JLabel or a JPanel (and its paintComponent()).
    when you add/remove components to the frame you will need to call
    frame.validate();, and possibly also
    frame.repaint();

  • How to get list of Pages in the Portal using JPDK API

    Hi All,
    I have number of JSP Pages binded in to different different war files deployed in to
    OAS server and also resides inthe portlet repository.Now problem is I would like to show that pages in the one Page as in links format should be in horizontal links using JPDK.
    Please help me out and any related examples which class will be solve the above problem.
    Thanks & Regards
    Sridhar Sabbani.

    Hi Sridhar,
    Do you mean links to portlets dropped onto the portal page? Or do you wish to access the links directly (i.e., access the portlet directly) ?
    thanks,
    Harsha

  • How to insert varchar2 40000 englist char to database.

    How to insert varchar2 40000 englist char to database use jdbc.
    My table is ut(varchar2(4000));]
    oracle version is 9.0

    Are you using the thin driver or the OCI driver? The Oracle Globalization Guide documents that the thin driver imposes more restrictive size limitations on character data than the Oracle database http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96529/ch9.htm#14068 You would need to ensure that you're using the OCI driver to work around these restrictions.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to get values/data stored in the database into a list-item.

    how to get values/data stored in the database into a list-item.
    i tried to make a list item without any values assigned to it...but i got the below error.
    FRM-30191: No list items defined for required poplist.
    or
    FRM-32082: Invalid value for given item type.
    List EMPNO
    Item: EMPNO
    Block: EMP
    Form: MODULE5
    FRM-30085: Unable to adjust form for output.
    then according to some docs, i tried the the following for the trigger
    when-new-form-instance
    declare
         rg_name varchar2(40) := 'emp_rec';
         status number;
         groupid recordgroup;
         it_id item;
    begin
         it_id := Find_Item('empno');
         groupid := create_group_from_query(rg_name, 'select empno from emp');
         status := populate_group(groupid);
         populate_list(it_id, groupid);
    end;
    but yet didnt work... :(
    so how the heck do i get values fetched from the database table into the list item?

    for list items you need to values in the record group, one is the shown value and one is the returned value.
    Check out the online help for the populate_list built-in.
    You'll need something like select ename,ename from emp as the record group query.

  • How to insert a sound recording and save it to iTunes?

    How to insert a sound recording and save it to iTunes?
    I have 5 voice recording on my iPhone, but the fifth was not detected on iTunes.So i can't sync

     
    Hi,
    According to my analysis, for Digital Signatures: Adobe has changed the behavior around digital signatures and SharePoint-hosted PDF files. Now, when digitally signing a SharePoint-hosted PDF file, it will be saved directly to SharePoint if that PDF file
    is already checked out. If not, the user will be prompted to check it out. When digitally signing a SharePoint-hosted PDF file in Acrobat X, Version 10.0, the user would be prompted to save that file locally and would then need to upload it separately to SharePoint
    as a new version.
    I suggest that you use Acrobat X, then check the result. For more information about Acrobat X, please refer to
    http://blogs.adobe.com/pdfitmatters/2011/06/whats-new-in-acrobat-x-version-10-1.html
    In addition, you can also consider the following third-party tool:
    http://www.arx.com/digital-signature/sharepoint
    Thanks,
    Rock Wang

  • How to insert list or library documents to custom db

    Hi All,
    I have small requirement how to insert the list or library documents to Custom Database using server object model.
    Thank,
    Raj

    Hi,
    According to your description, my understanding is that you want to insert some list items to a custom database using Server Object Model.
    I suggest you can read some list field value you want using SPList and
    SPListItem Object, then you can use SqlConnection and
    SqlCommand object insert value to your custom database.
    Here are some detailed code demos for your reference:
    How to: Read the Value of a Field in a List Item
    Beginners guide to accessing SQL Server through C#
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Insert multiple rows of records into the database

    The codes below allow me to insert a row of record into the database. How would I changed these to insert multiple rows at once? Please help!
    String sql = "INSERT INTO EMPLOYEES" +
    "(First_Name, Last_Name, Title, Phone) " +
    " VALUES " +
    PreparedStatement statement = conn.prepareStatement(sql);
    statement.setObject (1, First_Name);
    statement.setObject (2, Last_Name);
    statement.setObject (3, Title);
    statement.setObject (4, Phone);
    boolean returnValue = statement.execute();

    Hi mystiqueX,
    As wmolosho has suggested in his answer to this very same question that you also posted to the JavaServer Pages forum, you can create a batch of inserts and perform them using the "executeBatch()" method. I will use Craig's sample code to demonstrate:
    (Note that this code is untested!)
    conn.setAutoCommit(false);
    PreparedStatement statement = conn.prepareStatement(sql);
    // assume you have an array of objects here
    for (int i = 0; i < data.length; i++) {
      statement.setString(1, data<i>.getFirstName());
      statement.setString(2, data<i>.getLastName());
      statement.setString(3, data<i>.getTitle());
      statement.setString(4, data<i>.getPhone());
      statement.addBatch();
    statement.executeBatch();
    conn.commit();If you are not familiar with it, allow me to suggest looking at the Making Batch Updates lesson on the Java Tutorial.
    Hope it helps.
    Good Luck,
    Avi.

  • Best way to insert millions of records into the table

    Hi,
    Performance point of view, I am looking for the suggestion to choose best way to insert millions of records into the table.
    Also guide me How to implement in easier way to make better performance.
    Thanks,
    Orahar.

    Orahar wrote:
    Its Distributed data. No. of clients and N no. of Transaction data fetching from the database based on the different conditions and insert into another transaction table which is like batch process.Sounds contradictory.
    If the source data is already in the database, it is centralised.
    In that case you ideally do not want the overhead of shipping that data to a client, the client processing it, and the client shipping the results back to the database to be stored (inserted).
    It is must faster and more scalable for the client to instruct the database (via a stored proc or package) what to do, and that code (running on the database) to process the data.
    For a stored proc, the same principle applies. It is faster for it to instruct the SQL engine what to do (via an INSERT..SELECT statement), then pulling the data from the SQL engine using a cursor fetch loop, and then pushing that data again to the SQL engine using an insert statement.
    An INSERT..SELECT can also be done as a direct path insert. This introduces some limitations, but is faster than a normal insert.
    If the data processing is too complex for an INSERT..SELECT, then pulling the data into PL/SQL, processing it there, and pushing it back into the database is the next best option. This should be done using bulk processing though in order to optimise the data transfer process between the PL/SQL and SQL engines.
    Other performance considerations are the constraints on the insert table, the triggers, the indexes and so on. Make sure that data integrity is guaranteed (e.g. via PKs and FKs), and optimal (e.g. FKs should be indexes on the referenced table). Using triggers - well, that may not be the best approach (like for exampling using a trigger to assign a sequence value when it can be faster done in the insert SQL itself). Personally, I avoid using triggers - I rather have that code residing in a PL/SQL API for manipulating data in that table.
    The type of table also plays a role. Make sure that the decision about the table structure, hashed, indexed, partitioned, etc, is the optimal one for the data structure that is to reside in that table.

Maybe you are looking for

  • W520: Partition & Re-Format HDD and then Re-Install Windows 7

    Greetings.  I'm new to Lenovo and new to actually owning a ThinkPad, although not completely new to ThinkPads in general, since I used company-supplied ones when I worked for Big Blue (some time ago, now). Anyway, I just took delivery of my W520, and

  • "Share cannot be found" Help needed MAC to WIN XP

    I have a MBP and I am attempting to connect to a Win XP Desktop with a external USB hard drive attached. I can access through finder ANY share on ANY internal hard drive on the XP computer no problem. I can SEE any share I create on the USB hard driv

  • Safari not loading pages

    Since upgrading to OSX 10.5 Safari has failed to load certain sites e.g. www.engadget.com, these sites work perfectly in other web browsers on the same machine. The machine is a early Intel iMac. In the status bar at the bottom of safari it simply sa

  • How to find the host id in mac os X Mavricks

    I upgraded my Macbook storage. I took backup and restored all files and applications. everything is working good except Autodesk products. why ? Its saying Problem with Terminal, Check your server ID or Host ID.

  • Can I retrieve contacts that have been deleted?

    Can I retrieve contacts that have been deleted?