Submitt request to SQL table using C# WPF Application

I would like to submit request from WPF application to SQL table. My source is SharePoint list.
I am using Visual Studio 2008 for getting the Data from SharePoint List.
At the bottom I have Submit button which I want to use for inserting data into SQL table.
Below code is working fine for getting the data from SharePoint list. cmdGetRequests Button is working fine
I am new in programming any help be appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RequestsApp.WingtipSite;
using System.Data.SqlClient;
namespace RequestsApp
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class
Window1 : Window
public Window1()
            InitializeComponent();
private void cmdGetRequests_Click(object sender,
RoutedEventArgs e)
InformationGatewayDataContext dc =
new InformationGatewayDataContext(
new Uri("https://organization.xx./_vti_bin/ListData.svc"));
            dc.Credentials = System.Net.CredentialCache.DefaultCredentials;
var source = dc.Requests;
            listBox1.Items.Clear();
foreach (var dev
in source)
string devName = dev.ID +
" " + dev.FT + " " + dev.TX +
" " + dev.EG +
" " + dev.CompanyName + " " + dev.EmailAddr +
" " + dev.Flag +
" " + dev.StatusDate + " " + dev.Date +
" " + dev.Priority +
" " + dev.Source;
                listBox1.Items.Add(devName);
private void cmdSendRequests_Click(object sender,
RoutedEventArgs e)
simam

Thank you for the giving me right direction. I am able to get the list from SharePoint list into WPF application and submit data to SQL table.
Now I need to have Delete button which will delete the SharePoint list data. and then exit the application.
my Delete button is not working , I am using below code for deleting the list data
private void cmdDeleteRequests_Click(object sender,
RoutedEventArgs e)
InformationGatewayDataContext dc =
new InformationGatewayDataContext(
new Uri("https://organization.xx./_vti_bin/ListData.svc"));
            dc.Credentials = System.Net.CredentialCache.DefaultCredentials;
var source = dc.Requests;
            listBox1.Items.Clear();
foreach (var dev
in source)
string devName = dev.ID +
" " + dev.FT + " " + dev.TX +
" " + dev.EG + " " + dev.CompanyName +
" " + dev.EmailAddr + " " + dev.Flag +
" " + dev.StatusDate + " " + dev.Date +
" " + dev.Priority +
" " + dev.Source;
                listBox1.Items.Add(devName);
simam

Similar Messages

  • Error while retrieving data from PL/SQL Table using SELECT st. (Urgent!!!)

    Hi Friends,
    I am using Oracle 8.1.6 Server, & facing problems while retrieving data from a PL/SQL Table:
    CREATE or REPLACE PROCEDURE test_proc IS
    TYPE tP2 is TABLE of varchar2(10); --declared a collection
    dt2 tP2 := tP2('a','b','c');
    i NUMBER(8);
    begin
    SELECT COUNT(*) INTO i FROM TABLE(CAST(dt2 as tP2));
    DBMS_OUTPUT.PUT_LINE('**'||i);
    end;
    While executing the above procedure, I encountered foll. error:
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL execution], [], [],
    ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [], [], [], [], []
    ORA-06553: PLS-801: internal error [0]
    Can anyone please help me, where the problem is??
    Is it Possible to retrieve data from PL/SQL TABLE using SELECT statement? & How ?
    Thanks in advance.
    Best Regards,
    Jay Raval.

    Thanks Roger for the Update.
    It means that have to first CREATE TYPE .. TABLE in database then only I can fire a Select statement on that TYPE.
    Actually I wanted to fire a Select statement on the TABLE TYPE, defined & declared in PLSQL stored procedure using DECLARE TYPE .. TABLE & not using CREATE TYPE .. TABLE.
    I was eager to know this, because my organization is reluctant in using CREATE TYPE .. TABLE defined in the database, so I was looking out for another alternative to access PL/SQL TABLE using Select statement without defining it database. It would have been good if I could access a PLSQL TABLE using Select statement Declared locally in the stored procedure.
    Can I summarize that to access a PL/SQL TABLE using SELECT statement, I have to first CREATE TYPE .. TABLE?
    If someone have any other idea on this, please do let me know.
    Thanks a lot for all help.
    Best Regards,
    Jay Raval.
    You have to define a database type...
    create type tP2 is table of varchar2(10)
    CREATE OR REPLACE PROCEDURE TEST_PROC
    IS
    dt2 tP2 := tP2('a','b','c');
    i NUMBER(8);
    begin
    SELECT COUNT(*) INTO i FROM TABLE(CAST (dt2 AS tP2));
    DBMS_OUTPUT.PUT_LINE('**'||i);
    end;
    This will work.
    Roger

  • Calculate the sum of values in excel file and import it to SQL table using SSIS

    Hi,
    Can some one help me how to do auto sum of columns in SQL table  using SSIS
    in SQL table the HRA , PF and Basic should not come, Only it should appear in basic pay as the sum of HRA , PF and Basic...

    RSingh, Thanks for the use
    of derived column.
    Instead of using record set i used  OLE DB destination
    its working Fine...
    but now the issue is if i put a new records in excel file its replicating in SQL table 
    How to get only the changed values in excel to SQL table.

  • PL/SQL Table use in report region query

    Hello,
    I have a package function which return pl/sql table. I want to create a report region based on this pl/sql table. Is it possible to do this kind of report in HTMLDB?
    Please guide me in this area.
    Thanks
    HA

    The htmldb_collections API (apec_collections in 2.2) is a very useful method for rendering reports and one I have used extensivly in the past.
    Once created and populated you can reference your collection as if it were a SQL table i.e.
    Select c001, c002, c003
    from htmldb_collections
    where collection_name = 'MY_COLLECTION';
    You can absolutly base an Apex Report region on collections. Just treat them as another table that you can select from, join to others etc.
    In order to utilise this you must do the following:
    1) Create your collection:
    note that collections only persist for the duration of your session and you can only see the data you inserted into the collection. Also I would create this collection as the Database user who owns the Apex Workspace
    htmldb_collection.create_or_truncate_collection ('MY_COLLECTION');
    2) Populate your collection:
    In your case I would set a loop construct that parses through your pl/sql table and assign all values as described below. I assumed that my_plsql_tab has 3 columns called Val1, Val2, Val3
    FOR x IN 1..my_plsql_tab.count
    LOOP
    htmldb_collection.add_member (p_collection_name => 'MY_COLLECTION',
    p_c001 => my_plsql_tab(x).val1,
    p_c002 => my_plsql_tab(x).val2,
    p_c003 => my_plsql_tab(x).val3
    END LOOP;
    Note that you can have upto 60 elements in your collection.
    3) Access your collection:
    Select c001, c002, c003
    from htmldb_collections
    where collection_name = 'MY_COLLECTION';
    This quesry can then form the source of your sql report region.
    Hope all that helps
    Duncan

  • How can I read a file with ASCII Special Character into a SQL table using SSIS 2008?

    I've tried everything to read this file and am getting no where.   Help how can I read this file and load a SQL table?
    RS - AscII - 30  (Record Separator)
    GS - AscII - 29 (Group Separator)
    Thank you for your assistance - Covi
    Mark Covian

    We can use script component as source/transformation to read the text file and assign the contains to a string. Split the string by chr(30)  i.e RS and finally stored into an array or write to the output buffer of the script component.
    For example on how to use script component refer this link
    http://social.technet.microsoft.com/Forums/en-US/6ff2007d-d246-4107-b77c-624781baab38/how-to-use-substring-in-derived-column-in-ssis?forum=sqlintegrationservices
    Regards, RSingh

  • Error while connecting to external SQL table using BCS identity in SharePoint 2010

    Hi all,
    I am working on SharePoint Foundation 2010. I have a stand alone setup. Now I am trying to connect to a SQL table in another server. I have used SharePoint Designer to connect using BCS. I have selected "BCS Identity" for authenticating with SQL
    in the external content type. then I created a list with this external content type.
    I get the following error upon opening the external list.
    Login failed for user 'INYKGW\sp_farm'.
    I am confused. how do I solve this error.
    any help is greatly appreciated.
    Thanks.

    Hi letShare ,
    Whether the  account 'INYKGW\sp_farm' is current user account or a service managed account?
    Could you  please  provide detail error message of ULS log  to determine the exact cause of the error.
    For SharePoint 2010, by default, ULS log is at      
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS
    Also please have a look at  the blog :
    http://www.wonderlaura.com/Lists/Posts/Post.aspx?ID=82
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How to add hash table values to SQL Table using Powershell

    Hi,
    I have sharepoint list with four(column1, column2, column3,column4)columns.I am reading the list column values and adding to hashtable. Now I want to add values from hastable to SQL table with four(column1, column2, colum3,column4)columns using powershell.
    I have written the following script for single column but I would like to know how to add values for multiple columns.
                if(($key -eq "Column1") )
                   $SqlQuery = "INSERT INTO [TableName] ([Column1]) VALUES ('" + $HashTable.Item($key) +"')"
                   #Set new object to connect to sql database
                   $connection = new-object system.data.sqlclient.sqlconnection
                   $Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
              $connection #List connection information 
                   $connection.open() #Open Connection
                 $Cmd = New-Object System.Data.SqlClient.SqlCommand
                 $Cmd.CommandText = $SqlQuery
                   $Cmd.Connection = $connection
                  $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
                  $SqlAdapter.SelectCommand = $SqlCmd
                  $DataSet = New-Object System.Data.DataSet
                  $SqlAdapter.Fill($DataSet)
                  $DataSet.Tables[0]
                  $connection.Close()
    Can anybody please help me out to accomplish the task? Any help would be greatly appreciated.
    AA.

    Hi AOk2013,
    Not knowledgable on PowercShell, based on my understanding on HashTable in Java, Some modification you can make in your code to achieve your requirement.
    If the Keys in HashTable are "Column1","Column2","Column3","Column4", you can reference below.
    if(($key -eq "Column1") ) #what is the purposed of this if ?
    #$SqlQuery = "INSERT INTO [TableName] ([Term]) VALUES ('" + $HashTable.Item($key) +"')"
    #specify the real column names in the table
    $SqlQuery = "INSERT INTO [TableName] ([ColumnA],[ColumnB],[ColumnC],[ColumnD]) VALUES ('" + $HashTable.Item("Column1") +"','"+ $HashTable.Item("Column2") +"','"+$HashTable.Item("Column3") +"','"+$HashTable.Item("Column4") +"')"
    #Set new object to connect to sql database
    $connection = new-object system.data.sqlclient.sqlconnection
    $Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
    $connection #List connection information
    $connection.open() #Open Connection
    $Cmd = New-Object System.Data.SqlClient.SqlCommand
    $Cmd.CommandText = $SqlQuery
    $Cmd.Connection = $connection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $DataSet.Tables[0]
    $connection.Close()
    Since your question is regarding PowerShell, I would suggest you post it in a dedicated
    PowerShell Forum. It is more appropriate and more experts will assist you.
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • Regarding hierarchy creation from sql tables using db / ud connect

    bw version 3.0 upgrading to 7.0
    sql version 2005.
    we had built a sql data mart which is being accesses by a number of reporting tools. BI is one of the systems connected to it. My requirement is to upload hierarchies like customer from the sql data mart in to BW.
    The sql tables are in a denormalized format like this,
    EMPLOYEE_ID LAST_NAME                 MANAGER_ID      LEVEL
            101 Kochhar                          100                             1
            108 Greenberg                        101                            2
            109 Faviet                           108                                3
    They say that all third party reporting tools will recognize the above format and it universal. <b>I wanted to know is there any setting in bw that will allow extraction of hierarchies from the above table format ? if not I can only think of arranging data in the format of BW transfer structure, similar to flat file load.</b>
    I want to know can I upload hierarchies from sql tables or should I create flat files from tables ?
    Inputs will be awarded points.
    Message was edited by:
            aravind sam

    generate datasource? see if this can help..
    RSA1-> SOURCE SYSTEM-> SELECT YOUR SOURCE SYSTEM-> RIGHT CLICK-> GENERATE SOURCE SYSTEM.
    Also check:
    DB connect ORACLE - table name not found
    Re: Bw With ORacle
    Datasource in DB Connect
    and OSS Notes: 518241
    assign points if useful ***
    Thanks,
    Raj

  • Problem connecting to external SQL table using BCS in SharePoint Foundation 2010

    Hi all,
    I am working on SharePoint Foundation 2010. I have a requirement wherein I need to connect to SQL in some other server.
    I used BCS to create external content type and then I created an external list. now when I try to view the list on browser it says "Login failed for the user NT AUTHORITY\ANONYMOUS LOGIN".
    I am using "User's Identity" for authentication with SQL.
    How can solve this issue. Please help.
    any help is greatly appreciated.
    Thanks.

    That sounds like you might not be using Kerberos and/or your Kerberos authentication isn't working to pass your credentials.
    As you may know there's a limitation with NTLM permissions that prevents something known as the 'double hop'. This is where a server (SharePoint for example) tries to request things on your behalf. With NTLM you can't do this at all, the alternative is to
    use Kerberos which can handle double hops. One thing to know about Kerberos, if it's not completely set up right then IIS and SharePoint will almost always revert to NTLM so it's easy to think you've enabled it only to discover it's failing and you're really
    using NTLM.
    This guide will take you through setting up Kerberos in painful detail, it's great:
    http://www.microsoft.com/en-us/download/details.aspx?id=23176

  • Get the Last Value of Status Field from SQL TABLE using SQL 2008

    I have a table with Fields such as
    UploadstartTime, UploadEndtime, STATUS From TBLA.
    The STATUS Field, has values =7 and 11 are failed and 12 is SUCCESS. I cannot do a max, since it will always show 12, I need to get the MAX(UPLOADENDTIME, and get STATUS For that record. How can I do that using 1 SQL Query?
    My current code is: The issue is
    select
      TBLNAME
    MaxUploadstarttime
    =
    max(UploadStartTime),
    MaxUploadEndtime
    =
    max(UpLoadEndTime),
         Status=max(status)
    from  DB.DBO.LOGTABLE
    p1

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. You failed! Temporal
    data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    >> I have a table with Fields such as <<
    Fields are not columns! There is no generic status in RDBMS. Putting “tbl-” in a table name is called tibbling and we make fun of people who do it (Google Phil Factor's humor columns. If you were polite is this what you wanted to post? 
    CREATE TABLE Something_Uploads
    (upload_source_name CHAR(15) NOT NULL,
     upload_start_timestamp DATETIME2(0) NOT NULL,
     PRIMARY KEY (upload_source_name, upload_start_timestamp),
     upload_end_timestamp DATETIME2(0),
     CHECK(upload_start_timestamp < upload_end_timestamp),
     upload_status INTEGER NOT NULL 
       CHECK (upload_status IN (7,11,12, ..))
    >> I cannot do a max, since it will always show 12, I need to get the MAX(UPLOADENDTIME, and get upload_status For that record [sic]. How can I do that using 1 SQL Query?  <<
    Since you told us nothing and gave no sample data, want to correct this postign? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to get the incoming filename and store it to sql table using biztalk server 2013

    HI,
    1)I need to get the incoming EDI filename which is received and save the filename in to the database.
    2)How can i get the EDI Duplicate filename if i set the do not allow duplicate under validation tab in X12 agreement settings in biztalk admin console. In this case since the duplicate file will not come in to orchestration. In this case how
    can i acheive this.
    Thanks,
    Vijayan
    vijayan

    For both cases, the filename can be found on the FILE.ReceivedFileName Context Property.  You can access this Property in a Pipeline Component or Orchestration and take any action you want, such as apply to a database.
    The value is accessed by: MyReceivedMessage(FILE.ReceivedFileName)
    In the case of a duplicate EDI Interchange, you would use the Failed Message Routing feature to capture the error message with either an Orchestration or Send Port.

  • SharePoint list to sql table using client object model

    here is my code 
    static void Main(string[] args)
    ClientContext context = new ClientContext("http://sp2010");
    Web web = context.Web;
    List list = context.Web.Lists.GetByTitle("Emp");
    context.Load(list);
    context.ExecuteQuery();
    Console.WriteLine(list.Title + "\n");
    CamlQuery query = new CamlQuery();
    query.ViewXml = "<View/>";
    ListItemCollection allitems = list.GetItems(query);
    context.Load(allitems);
    context.ExecuteQuery();
    foreach (ListItem listitem in allitems)
    Console.WriteLine(listitem["desc"].ToString());
    string connString = "connection string";
    string a = "insert into emp";
    SqlConnection conn = new SqlConnection(connString);
    SqlCommand cmd = new SqlCommand(a, conn);
    conn.Open();
    // create data adapter
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    // this will query your database and return the result to your datatable
    // da.Fill(dataTable);
    conn.Close();
    da.Dispose();
    DataTable table = new DataTable();
    table.Columns.Add("desc");
    DataRow row = table.NewRow();
    table.Rows.Add(row);
    //Console.WriteLine("row added");
    da.Fill(table);
    Console.Read();

    Excel + PowerPivot.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • How to access SQL tables from WebDynPro ABAP application ?

    Hi,
    I am trying a scenario, where I need to send an user ID to SQL server table (update/modify/delete) from webDynpro ABAP application.
    Basically ,I am trying to know:---
    a>How to write a SQL Connection from ABAP code within webdynpro ABAP application
    b>What are the ways to do it.(by code or any other API/mechanism)
    I appreciate if anybody knows this.
    Thanks
    Praveen

    Hi,
    The EXEC CONNECT ... is usually used in the procedural ABAP code. For this you can refer to the ABAPDOCU.
    I dont have any sample code on the classes I listed try to check out them for the parameters and the methods they have.
    In WD for Java, we have these connection classes to connect to any databsae server.
    Or try to create an RFC with DESTINATION for this
    Pls check out this link for this -
    Pull data from another r3 server using abap dynpro
    Regards
    Lekha

  • SQL server 2014 and VS 2013 - Dataflow task, read CSV file and insert data to SQL table

    Hello everyone,
    I was assigned a work item wherein, I've a dataflow task on For Each Loop container at control flow of SSIS package. This For Each Loop container reads the CSV files from the specified location one by one, and populates a variable with current
    file name. Note, the tables where I would like to push the data from each CSV file are also having the same names as CSV file names.
    On the dataflow task, I've Flat File component as a source, this component uses the above variable to read the data of a particular file. Now, here my question comes, how can I move the data to destination, SQL table, using the same variable name?
    I've tried to setup the OLE DB destination component dynamically but it executes well only for first time. It does not change the mappings as per the columns of the second CSV file. There're around 50 CSV files, each has different set off columns
    in it. These files needs to be migrated to SQL tables using the optimum way.
    Does anybody know which is the best way to setup the Dataflow task for this requirement?
    Also, I cannot use Bulk insert task here as we would like to keep a log of corrupted rows.
    Any help would be much appreciated. It's very urgent.
    Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.com

    The standard Data Flow Task supports only static metadata defined during design time. I would recommend you check the commercial COZYROC
    Data Flow Task Plus. It is an extension of the standard Data Flow Task and it supports dynamic metadata at runtime. You can process all your input CSV files using a single Data Flow Task
    Plus. No programming skills are required.
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • SAP Note regarding manually updating SQL tables

    Hi all,
    I know that under no circumstances should customers update their SQL tables using any method expect DTW or via SAP.
    Is there an SAP Note on this subject.  I cannot find one anywhere?
    Thanks
    Greig

    Check this SAP Note: 896891     Support Scope for SAP Business One - DB Integrity
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E&note_numm=896891]

Maybe you are looking for