C# :: Run SQL Query For Each Item In Listbox?

Aug 2, 2014

I have a C# WPF program that takes a SQL query and populates a column from an Oracle database into a listbox on the form. I would like to be able to compare all items populated in the listbox, and run a SQL query for each item, populating those values into a different listbox.

So far, I have this code:

string sql2 = "select unique apps.fnd_application_all_view.application_name, fnd_responsibility_vl.responsibility_name, fnd_form_functions_tl.user_function_name, fnd_form_functions.function_name, fnd_form_functions_tl.description, fnd_form_functions.type FROM fnd_compiled_menu_functions, fnd_form_functions, fnd_form_functions_tl, fnd_responsibility, fnd responsibility_vl, apps.fnd_application_all_view WHERE

[code]....

I would like to be able to basically take the "Responsibility_Name" value from the first listbox (lstResponsibilities), which is already populated, and use those values to in the "sql2" query to find the "Function_Name" and populate "Function_Name" in the second listbox (lstFunctions).

View 5 Replies


ADVERTISEMENT

C/C++ :: Get The Position Of A Selected Item In A ListBox

Jul 21, 2014

I've a winapi listbox with a bunch of entries, I'd like that when the user click on an entry, the entry number will be saved on an integer variable.

View 3 Replies View Related

C Sharp :: Listbox Item Display - How To Add Column From File To Combobox

Oct 4, 2012

How to display the item in listbox,which are selected from three combobox.

View 1 Replies View Related

C Sharp :: How To Set Rootpath Of Application Which Is Path Of A Selected Item In Listbox

Apr 4, 2013

I want to set the rootpath of an executable application. This rootpath should be the same as the path of an item that I select from a ListBox. The code for selecting the item is as follows.

namespace Menu {
    public partial class Form1 : Form {  
        private Button button;
        private ListBox listBox1;
        private string selecteditem;

[Code] ....

Now what I want is: Whatever I get the output as in the :

Console.Writeline(path + selecteditem),

I would want to set this as a rootpath for an application so as to do rest of the measurements or steps only in that path/folder. Is it possible to do something like this?

View 8 Replies View Related

C# :: Moving Listbox Selection To New Listbox In New Form?

Sep 11, 2014

Okay so i have everything right accept transfering the selectedindex from listbox in form1 to listbox in form2. I am using the below string item to hold the selected line of the list box, with the intent of recalling and then adding it into the form2 listbox. I get a not implemented error and i can't figure out why. I know the information is moving with the variable item, it just doesn't get printed out to the new listbox.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
Form2 form2 = new Form2();
form2.Show(item.ToString());

[Code]....

View 13 Replies View Related

Visual C++ :: Enable / Disable Menu Item 2 In OnUpdate Handler Of Menu Item 1?

Sep 15, 2014

I have two menu items. When item 1 is disabled, I want item 2 to be disabled as well. In the OnUpdate handler of menu item 1, I have tried to use "t_pMenu = pCmdUI->m_pMenu;", "t_pMenu = pCmdUI->m_pSubMenu;" and "t_pMenu = pCmdUI->m_pParentMenu;" but I always get NULL t_pMenu. How can I achieve this purpose?

Code:
void CDummyView::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
if(m_bShowMenuItem1) {
pCmdUI->Enable(TRUE);

[Code]....

View 14 Replies View Related

C# :: Populating GridView With SQL Query

Apr 3, 2014

I have two tables

Orders
ID, CreatedDate,CustomerID
1, 03/04/2014, test

OrderDetails
ID,ProductId, ProductName,Quantity,Price,Total
1, 5, Toy, 5, 1.99, 9.95

I have a gridview, im using its 'datasource dropdownlist' to populate it, i have the SQL statement

SELECT Orders.ID, OrderDetails.ProductId, OrderDetails.ProductName, OrderDetails.Quantity, OrderDetails.Price, OrderDetails.Total FROM (OrderDetails INNER JOIN Orders ON OrderDetails.ID = Orders.ID) WHERE (Orders.CustomerId = ?)

where the '?' is parameters source = QueryString, and QueryStringField= email

i have a session that is the customerEmailId, so

string CustomerEmailID = (string)Session["email"];
Response.Redirect("MyAccount.aspx?email=" + CustomerEmailID);//i have tested it and customerEmailid is test
however nothing loads in the GridView

View 1 Replies View Related

C++ :: Generate List Of Tokens For A Query

Jun 9, 2013

I'm trying to solve the following problem:

Given a query, find all possible tokens, i.e. query-splits

Example:
query = New York Hotel
tokens = {New, York, Hotel, New York, New Hotel, ...., New Hotel York, Hotel New York, ...}

Given a query with word count n, the total number of tokens is:
n + n*(n-1) + n*(n-1)*(n-2) + ... + n! (any explicit formula available for this sum?)

Now, I have came across various code snippets to generate permutations for a string, but never for a sentence.

View 13 Replies View Related

C# :: Combine Query To Show All Data

Sep 22, 2014

So I've been working on this for awhile and FINALLY got it to work. This is my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

[Code] ....

As you can see I will have the Name and total right next to eachother.. Problem is I dont want to make a million MySQLCommands for each ID.. Is there a Way I can list all data in each label?

For instance the Select from Text will show all the text from each different ID
and the Select from STOCK-USED as total will show all the total for each ID

Instead of having to list them individually.

Even if I leave it to this

"Select text FROM `parts`";

It selects the 2nd ID in my database and displays its text.. Forgets about the first one completely ...

View 2 Replies View Related

C# :: How To Avoid Duplicate Updates In SQL Query

Jun 13, 2014

I have table called leavetable where in i have the fields eid, lfrom,lto, reason,status an employee will insert these fields in the leave form except status, status will be updated by admin but there is no unique field in the table so when the admin updates the status as cancel for an id emp001 so whereever this id is present in the table its getting updated to cancel even though it is approved previously.. How to avoid this duplication ?

SqlConnection con = new SqlConnection(Connectionstring);
con.Open();
string sql = "update leavetable set status = '"+status+"' where eid = '"+textBox1.Text+"' and noofdays = '"+textBox5.Text+"'";

[Code] .....

View 7 Replies View Related

C# :: How To Pass SQL Parametrized Query To WCF Web Service

Nov 16, 2014

I have WCF web service which contains methods for communicating with database (ms sql). For a long time I was using pure sql statements, that aren't secure. It is time to move to parameterized queries. I'm using code-engine.com source code for query builder. Example of it is here: SelectQueryBuilder: Building complex and flexible SQL queries/commands from C# . Which works OK and I have no problems when is used inside of web service.

The problem: I also have asp.net web site which uses this webservice and the main problem is, how to build queries on client side and sent them to web service? I can build query on client side and send dbCommand.commandtext but I then I don't know how to send parameters list to webservice, because it isn't serialized.

This would be used as "universal" method for sql statements. I have others method like getUser(),getUsers(),getPages() but I really need this kind of methods to pass query to it.

View 1 Replies View Related

C# :: Update Multiple Tables In One Query?

Jul 23, 2014

i'm trying to update multiple table values with same column using one query.

Here's what i've tried so far:

mySql.CommandText = "Update tbl_employees,tbl_emp_additional_info,tbl_allocated_deductions,tbl_benefits,
tbl_cashadvances,tbl_deduction_history,"+
"tbl_dtr,tbl_empabsences,tbl_empstatus,tbl_otherdeductions
,tbl_ots,tbl_payroll_history,tbl_rdcomments,tbl_reversed_deductions,tbl_reversed_deduction_paid "+
"set tbl_employees.emp_id=@newemp_id,tbl_emp_additional_info.emp_id=@newemp_id,tbl_allocated_deductions.

[code]...

I've also tried removing all the other "and" operators but still no luck.It doesn't throw in exception yet it doesn't update my tables column values.

View 14 Replies View Related

C# :: Including A String In SQL Query For Excel Spreadsheet

Jan 15, 2015

I am displaying data from an Excel Spreadsheet through an ASP.net web form using C#. I would like to run an SQL query on the data, but am having trouble figuring out how to use a string in my query.

Here is the code I am running in my .aspx.cs file. I am also using a .aspx to display the data in a GridView.

public partial class ExcelAdapter : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("ExcelCSTest.xls") + ";" + "Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"";

[Code] ....

Ideally, I would like to add a WHERE clause to my string (string sSQL = "SELECT * FROM [Sheet1$A1:D14]"/> in order to query the current month and display the row of said month from the Excel Spreadsheet.

I have attempted to use a DataAdapter to insert the string into the query, but could not figure out how to conform my code to work with it.

View 1 Replies View Related

C# :: Multiple Update Query After Filter In Datagridview

Oct 11, 2014

I'm new to c# and i'm using vs 2013 and access database..my i need to do multiple update records after I filtered the records in datagridview

In my database table I have these fields ID(PK/autonumber), EID,Date,Day,Daystatus..

In my form I have a button and it's fucntion is filter by date using bidingsource.fiter and this was the result

EID------Date-----------Day---Daystatus
10175--10/11/2014---sat--------regular
10176--10/11/2014---sat--------regular
10177--10/11/2014---sat--------regular
10178--10/11/2014---sat--------regular

what I want to happen is when I click another button called "Apply to all" I want to Update all the daystatus to "Legal Holiday" of the filtered records..I know how to update one by one using simple update..but I need to do the multiple update..

I tried to make a code but it was updating all the records not the filtered only here's my code:

try {
OleDbCommand command = new OleDbCommand();
connection.Open();
command.Connection = connection;
string query = "SELECT EID From EmployeeTable";
command.CommandText = query;
String a = "Legal Holiday";

[Code] ......

View 1 Replies View Related

C Sharp :: Using List Elements As Variable In Query

Aug 27, 2014

I am trying to query an Informix database using a List<T> collection's elements as variables. I can build the list and connect to the database, but I am unsure how to iterate through the list and query the database for each item in the collection.

My list is of type string, and contains Order Numbers. I want to query item information for each order number in the list.

View 1 Replies View Related

C++ :: Bool Algebra - Designing Database Query

May 15, 2012

I am designing a database query and need simplification to the algebra:

Code:
((x > u) && (x < y)) || ((z > u) && (z < y)) || ((u > z) && (y < x))

And these are always true:

Code:
z > x
u > y

It's a range overlap algorithm.

View 4 Replies View Related

Visual C++ :: LINQ Query To Select Distinct Value From Datatable

Oct 29, 2013

I entered to Visual C++ 2010. Now my intention is to prepare a LINQ Query to select a distinct value from a datatable...

In C# My Query
============
var ProjLnkQry = (from P in MyClass1.ProjTbl.AsEnumerable() select P["proj_name"]).Distinct().ToList();

The above query I try to convert it into VIsual C++

auto DistDepQry=(from v1 in MyGlobalData::ProjectTbl::AsEnumaerable() select v1["depart_name"])->Distinct()->ToList();

But not succeeded.... I found the error like : "from" undeclared Identifier.....

View 2 Replies View Related

C# :: Linq To SQL Query Not Directly Working But SQL Result Text Works

Apr 14, 2015

I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.

However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:

DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);

and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.

var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);

View 8 Replies View Related

C Sharp :: Open Excel File / Refresh Query And Save

Oct 3, 2012

I am trying to open an Excel file, refresh the query behind it and then save and close the file in C#.

I have the following but I am getting errors on the

 Application excel = new Application()

section:

            Application excel = new Application();
            Workbook theWorkbook = excelFile.Workbooks._Open(txtLocation.Text, 0, false, 5, System.
Reflection.Missing.Value, System.Reflection.Missing.Value, false, System.

[Code] .....

I have added the Microsoft.Office.Interop.Excel reference, but still have the issue?

View 1 Replies View Related

C Sharp :: Syntax Error In Update Query Using MA Access Database And Net 4.0

Feb 21, 2014

private void update_Click(object sender, EventArgs e)  {
            OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:UsersshobhitDocumentsEnvironment_Monitoring.accdb;
Jet OLEDB:Database Password=divya6");
            String sdat = dateTimePicker1.Value.ToShortDateString();
            String la = labs.SelectedItem.ToString();

[Code] ....

View 1 Replies View Related

Visual C++ :: Read Table And Get All PNAME Into Combobox - Reduce Query Execution Time

Nov 14, 2014

My table:

Code:
Database name: test & Table name : Profilemaster
+-----+--------+
| PID | PNAME |
+-----+--------+
| 1 | APPLE1 |
| 2 | APPLE2 |
| 3 | APPLE3 |
| 4 | APPLE4 |
| 5 | APPLE5 |
| 6 | APPLE6 |
| 7 | APPLE7 |
| 8 | APPLE8 |
| 9 | APPLE9 |
| 10| APPLE10 |
+-----+--------+

I like to read the table and get the all PNAME into the combo box.

Using the below code i can read the table, but while loop takes 2 seconds to read 10 records in the Profilemaster table.
How can i reduce the reading time?

My Code is
void MainScreen::OnreadProfileName() {
CDatabase database;
CString SqlString;
CString sDsn;
CString pname;

sDsn.Format("Driver={MySQL ODBC 5.2 ANSI Driver};Server=localhost;Database=test;User=root;Password=client;Option=4;");

[Code] ....

Is any other way to reduce the query execution time?

View 6 Replies View Related

C# :: Using Array In Listbox?

Jun 2, 2014

My main form I have the following code

[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<AudioPlugin> content)
{

[Code].....

However, when I add to the listbox as shown above in my main form code the results all show on the same line. My understanding was that they should all be treated as separate because of foreach loop but apparently that is incorrect. I have seen mixed things online some showing that its required to use AddRange instead of Add, however, after literally hours of trying to make this work I am still coming up with nothing. I can't seem to get any code to work using the AddRange or am I finding any way to output each results on a separate line.

View 7 Replies View Related

C++ :: Listbox SendMessage Not Working

Jun 25, 2013

I have a problem with SendMessage. Anything I send doesn't show up but instead empty lines appear. What is wrong with my code?

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");
wchar_t listBoxStr[15];

[code].....

View 7 Replies View Related

C# :: Invert ListBox Selection?

Apr 18, 2014

I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.

I tried using:

if (lstLinePatterns == null) return;
for (int i = 0; i < lstLinePatterns.Items.Count; i++)
lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;

But
.Selected
is giving me an object error.

Is there an easy way to just inverse current selection?

Current Code:

private void btnSelectNonRvt_Click(object sender, EventArgs e)
{
// Unselects any Items to Prevent Infinite Loop
lstLinePatterns.SelectedIndex = -1;

[Code]....

View 3 Replies View Related

C# :: Clear A Listbox From A Class?

Jun 5, 2014

I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.

Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:

MyForm

public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}

View 9 Replies View Related

C# :: Two Checked Listbox - One Interacts With Other

Aug 31, 2014

I am working on a Windows From application on Visual Studio 2010 where i need to use two checkedlistbox that interacts one with the other one. Let say that the first checkedlistbox is for world regions (i.e.):

Asia
Africa
Europe
South America

And let say that the second checkedlistbox is for Countries (i.e.):

Spain
Italy
Romania
Monaco

(all of this belongs to Europe region)

What we need to do is that when the user check on any world region it automatically checks all the countries on that region in the second checkbox, and vice versa if the users check any country on the second checkedlistbox it automatically seconds the region on the first one.

I know that is possible in Java and we know how to do it, but i don't know if C# supports this and how to do it. I was looking on the class information in the microsoft website: [URL] .... but not a concrete example on how to do it.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved