Search Results

Search found 177 results on 8 pages for 'emp'.

Page 5/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Embedding generic sql queries into c# program

    - by Pooja Balkundi
    Okay referring to my first question code in the main, I want the user to enter employee name at runtime and then i take this name which user has entered and compare it with the e_name of my emp table , if it exists i want to display all information of that employee , how can I achieve this ? using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace ConnectCsharppToMySQL { public class DBConnect { private MySqlConnection connection; private string server; private string database; private string uid; private string password; string name; //Constructor public DBConnect() { Initialize(); } //Initialize values private void Initialize() { server = "localhost"; database = "test"; uid = "root"; password = ""; string connectionString; connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; connection = new MySqlConnection(connectionString); } //open connection to database private bool OpenConnection() { try { connection.Open(); return true; } catch (MySqlException ex) { //When handling errors, you can your application's response based //on the error number. //The two most common error numbers when connecting are as follows: //0: Cannot connect to server. //1045: Invalid user name and/or password. switch (ex.Number) { case 0: MessageBox.Show("Cannot connect to server. Contact administrator"); break; case 1045: MessageBox.Show("Invalid username/password, please try again"); break; } return false; } } //Close connection private bool CloseConnection() { try { connection.Close(); return true; } catch (MySqlException ex) { MessageBox.Show(ex.Message); return false; } } //Insert statement public void Insert() { string query = "INSERT INTO emp (e_name, age) VALUES('Pooja R', '21')"; //open connection if (this.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command cmd.ExecuteNonQuery(); //close connection this.CloseConnection(); } } //Update statement public void Update() { string query = "UPDATE emp SET e_name='Peachy', age='22' WHERE e_name='Pooja R'"; //Open connection if (this.OpenConnection() == true) { //create mysql command MySqlCommand cmd = new MySqlCommand(); //Assign the query using CommandText cmd.CommandText = query; //Assign the connection using Connection cmd.Connection = connection; //Execute query cmd.ExecuteNonQuery(); //close connection this.CloseConnection(); } } //Select statement public List<string>[] Select() { string query = "SELECT * FROM emp where e_name=(/*I WANT USER ENTERED NAME TO GET INSERTED HERE*/)"; //Create a list to store the result List<string>[] list = new List<string>[3]; list[0] = new List<string>(); list[1] = new List<string>(); list[2] = new List<string>(); //Open connection if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { list[0].Add(dataReader["e_id"] + ""); list[1].Add(dataReader["e_name"] + ""); list[2].Add(dataReader["age"] + ""); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); //return list to be displayed return list; } else { return list; } } public static void Main(String[] args) { DBConnect db1 = new DBConnect(); Console.WriteLine("Initializing"); db1.Initialize(); Console.WriteLine("Search :"); Console.WriteLine("Enter the employee name"); db1.name = Console.ReadLine(); db1.Select(); Console.ReadLine(); } } }

    Read the article

  • Something similar to this C# code in Ruby on Rails

    - by Jimmy
    Hey guys, I am trying to get a collection of objects based on a conditions. Now normally in C# I would do something like this employeesCollection.Where(emp => emp.Name == "john"); how can I do something similar in Ruby on Rails (I am trying to map a collection of objects to a select but I only want to map certain objects that match a condition. My current ruby on rails code looks like this <%= select( 'page', 'id', @post.pages.map {|page| [page.title, page.id]}) %> I want to add a condition to an attribute of page Can anyone help?

    Read the article

  • Stored Procedure to create Insert statements in MySql ??

    - by karthik
    I need a storedprocedure to get the records of a Table and return the value as Insert Statements for the selected records. For Instance, The stored procedure should have three Input parameters... 1- Table Name 2- Column Name 3- Column Value If 1- Table Name = "EMP" 2- Column Name = "EMPID" 3- Column Value = "15" Then the output should be, select all the values of EMP where EMPID is 15 Once the values are selected for above condition, the stored procedure must return the script for inserting the selected values. The purpose of this is to take backup of selected values. when the SP returns a value {Insert statements}, c# will just write them to a .sql file. I have no idea about writing this SP, any samples of code is appreicated. Thanks..

    Read the article

  • How to use multiple database in a PHP web application?

    - by Harish
    I am making a PHP web Application in which i am using MySQL as database server, i want to make backup of some tables from one database to another database(with that tables in it). i have created two different connection, but the table is not updated. $dbcon1 = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD) or die(mysql_error()); $dbase1 = mysql_select_db(TEMP_DB_NAME,$dbcon)or die(mysql_error()); $query1=mysql_query("SELECT * FROM emp"); while($row = mysql_fetch_array($query1, MYSQL_NUM)) { $dbcon2 = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD) or die(mysql_error()); $dbase2 = mysql_select_db(TEMP_DB_NAME2,$dbcon)or die(mysql_error()); mysql_query("INSERT INTO backup_emp VALUES(null,'$row[1]',$row[2])"); mysql_close($dbcon2); } the code above is taking the data of emp from first database, and updataing it into another backup_emp table of another database. the code is not working properly, is there any other way of doing this...please help.

    Read the article

  • linq to sql update data

    - by pranay
    can i update my employee record as given in below function or i have to make query of employee collection first and than i update data public int updateEmployee(App3_EMPLOYEE employee) { DBContextDataContext db = new DBContextDataContext(); db.App3_EMPLOYEEs.Attach(employee); db.SubmitChanges(); return employee.PKEY; } or i have to do this public int updateEmployee(App3_EMPLOYEE employee) { DBContextDataContext db = new DBContextDataContext(); App3_EMPLOYEE emp = db.App3_EMPLOYEEs.Single(e => e.PKEY == employee.PKEY); db.App3_EMPLOYEEs.Attach(employee,emp); db.SubmitChanges(); return employee.PKEY; } But i dont want to use second option is there any efficient way to update data

    Read the article

  • Most efficient way to Update with Linq2Sql

    - by pranay
    can I update my employee record as given in below function or i have to make query of employee collection first and than i update data public int updateEmployee(App3_EMPLOYEE employee) { DBContextDataContext db = new DBContextDataContext(); db.App3_EMPLOYEEs.Attach(employee); db.SubmitChanges(); return employee.PKEY; } or i have to do this public int updateEmployee(App3_EMPLOYEE employee) { DBContextDataContext db = new DBContextDataContext(); App3_EMPLOYEE emp = db.App3_EMPLOYEEs.Single(e => e.PKEY == employee.PKEY); db.App3_EMPLOYEEs.Attach(employee,emp); db.SubmitChanges(); return employee.PKEY; } But i dont want to use second option is there any efficient way to update data

    Read the article

  • Finding employees specific to department in SQL SERVER 2000(SET BASED)

    - by xyz
    Suppose I have a table (tblEmp) whose structure is like as under Dept Emp d1 e1 d1 e2 d1 e3 d2 e4 d2 e5 d3 e6 If I need to bring the output as Dept DepartmentSpecificEmployees d1 e1,e2,e3 d2 e4,e5 d3 e6 I will write the query as select Dept, stuff((select Emp + ',' from tblEmp t2 where t1.Dept = t2.Dept for xml path(''),1,1,'')DepartmentSpecificEmployees from tblEmp t1 group by Dept But this will work in Sql Server 2005+. How can I achieve the same in Sql Server 2000 without any variable declaration or loop or cursor? If I use COALESCE as an alternative, then I need to use a variable which will defeat the purpose Please help

    Read the article

  • Drag & Drop in APEX-Anwendungen realisieren

    - by Carsten Czarski
    In diesem Tipp stellen wir Ihnen vor, wie Sie Drag & Drop in Ihrer APEX-Anwendung realisieren können. Das ist gar nicht so aufwändig, wie man denke, denn das in APEX enthaltene jQuery UI erledigt den Löwenanteil der Arbeit, so dass nur noch wenige JavaScript-Aufrufe abzusetzen sind. Lesen Sie, wie Sie in Ihrer eigenen APEX-Anwendung Zeilen aus der Tabelle EMP per Drag & Drop zu Zeilen der Tabelle DEPT zuordnen können.

    Read the article

  • Floating Panels and Describe Windows in Oracle SQL Developer

    - by thatjeffsmith
    One of the challenges I face as I try to share tips about our software is that I tend to assume there are features that you just ‘know about.’ Either they’re so intuitive that you MUST know about them, or it’s a feature that I’ve been using for so long I forget that others may have never even seen it before. I want to cover two of those today - Describe (DESC) – SHIFT+F4 Floating Panels My super-exciting desktop SQL Developer and Describe DESC or Describe is an Oracle SQL*Plus command. It shows what a table or view is composed of in terms of it’s column definition. Here’s an example: SQL*Plus: Release 11.2.0.3.0 Production on Fri Sep 21 14:25:37 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> desc beer; Name Null? Type ----------------------------------------- -------- ---------------------------- BREWERY NOT NULL VARCHAR2(100) CITY VARCHAR2(100) STATE VARCHAR2(100) COUNTRY VARCHAR2(100) ID NUMBER SQL> You can get the same information – and a good bit more – in SQL Developer using the SQL Developer DESC command. You invoke it with SHIFT+F4. It will open a floating (non-modal!) window with the information you want. Here’s an example: I can see my column definitions, constratins, stats, privs, etc A few ‘cool’ things you should be aware of: I can open as many as I want, and still work in my worksheet, browser, etc. I can also DESC an index, user, or most any other database object I can of course move them off my primary desktop display The DESC panel’s are read-only. I can’t drop a constraint from within the DESC window of a given table. But for dragging columns into my worksheet, and checking out the stats for my objects as I query them – it’s very, very handy. Try This Right Now Type ‘scott.emp’ (or some other table you have), place your cursor on the text, and hit SHIFT+F4. You’ll see the EMP object open. Now click into a column name in the columns page. Drag it into your worksheet. It will paste that column name into your query. This is an alternative for those that don’t like our code insight feature or dragging columns off the connection tree (new for v3.2!) Got it? SQL Developer’s Floating Panels Ok, let’s talk about a similar feature. Did you know that any dockable panel from the View menu can also be ‘floated?’ One of my favorite features is the SQL History. Every query I run is recorded, and I can recall them later without having to remember what I ran and when. And I USUALLY use the keyboard shortcuts for this. Let your trouble float away…if only it were so easy as a right-click in the real world. But sometimes I still want to see my recall list without having to give up my screen real estate. So I just mouse-right click on the panel tab and select ‘Float.’ Then I move it over to my secondary display – see the poorly lit picture in the beginning of this post. And that’s it. Simple, I know. But I thought you should know about these two things!

    Read the article

  • UTL_FILE.FOPEN() procedure not accepting path for directory ?

    - by Vineet
    I am trying to write in a file stored in c:\ drive named vin1.txt and getting this error .Please suggest! > ERROR at line 1: ORA-29280: invalid > directory path ORA-06512: at > "SYS.UTL_FILE", line 18 ORA-06512: at > "SYS.UTL_FILE", line 424 ORA-06512: at > "SCOTT.SAL_STATUS", line 12 ORA-06512: > at line 1 HERE is the code create or replace procedure sal_status ( p_file_dir IN varchar2, p_filename IN varchar2) IS v_filehandle utl_file.file_type; cursor emp Is select * from employees order by department_id; v_dep_no departments.department_id%TYPE; begin v_filehandle :=utl_file.fopen(p_file_dir,p_filename,'w');--Opening a file utl_file.putf(v_filehandle,'SALARY REPORT :GENERATED ON %s\n',SYSDATE); utl_file.new_line(v_filehandle); for v_emp_rec IN emp LOOP v_dep_no :=v_emp_rec.department_id; utl_file.putf(v_filehandle,'employee %s earns:s\n',v_emp_rec.last_name,v_emp_rec.salary); end loop; utl_file.put_line(v_filehandle,'***END OF REPORT***'); UTL_FILE.fclose(v_filehandle); end sal_status; execute sal_status('C:\','vin1.txt');--Executing

    Read the article

  • hibernate insert to a collection causes a delete then all the items in the collection to be inserted

    - by Mark
    I have a many to may relationship CohortGroup and Employee. Any time I insert an Employee into the CohortGroup hibernate deletes the group from the resolution table and inserts all the members again, plus the new one. Why not just add the new one? The annotation in the Group: @ManyToMany(cascade = { PERSIST, MERGE, REFRESH }) @JoinTable(name="MYSITE_RES_COHORT_GROUP_STAFF", joinColumns={@JoinColumn(name="COHORT_GROUPID")}, inverseJoinColumns={@JoinColumn(name="USERID")}) public List<Employee> getMembers(){ return members; } The other side in the Employee @ManyToMany(mappedBy="members",cascade = { PERSIST, MERGE, REFRESH } ) public List<CohortGroup> getMemberGroups(){ return memberGroups; } Code snipit Employee emp = edao.findByID(cohortId); CohortGroup group = cgdao.findByID(Long.decode(groupId)); group.getMembers().add(emp); cgdao.persist(group); below is the sql reported in the log delete from swas.MYSITE_RES_COHORT_GROUP_STAFF where COHORT_GROUPID=? insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) This seams really inefficient and is causing some issues. If sevral requests are made to add an employee to the group then some get over written.

    Read the article

  • Passing models between controllers in MVC4

    - by wtfsven
    I'm in the middle of my first foray into web development with MVC4, and I've run into a problem that I just know is one of the core issues in web development in general, but can't seem to wrap my mind around it. So I have two models: Employee and Company. Employee has a Company, therefore /Employee/Create contains a field that is either a dropdown list for selecting an existing Company, or an ActionLink to /Company/Create if none exists. But here's the issue: If a user has to create a Company, I need to preserve the existing Employee model across both Views--over to /Company/Create, then back to /Employee/Create. So my first approach was to pass the Employee model to /Company/Create with a @Html.ActionLink("Add...", "Create", "Organization", Model , null), but then when I get to Company's Create(Employee emp), all of emp's values are null. The second problem is that if I try to come back to /Employee/Create, I'd be passing back an Employee, which would resolve to the POST Action. Basically, the whole idea is to save the state of the /Employee/Create page, jump over to /Company/Create to create a Company record, then back to /Employee/Create to finish creating the Employee. I know there is a well understood solution to this because , but I can't seem to phase it well enough to get a good Google result out of it. I've though about using Session, but it seems like doing so would be a bit of a kludge. I'd really like an elegant solution to this.

    Read the article

  • ODI 12c - Aggregating Data

    - by David Allan
    This posting will look at the aggregation component that was introduced in ODI 12c. For many ETL tool users this shouldn't be a big surprise, its a little different than ODI 11g but for good reason. You can use this component for composing data with relational like operations such as sum, average and so forth. Also, Oracle SQL supports special functions called Analytic SQL functions, you can use a specially configured aggregation component or the expression component for these now in ODI 12c. In database systems an aggregate transformation is a transformation where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning - that's exactly the purpose of the aggregate component. In the image below you can see the aggregate component in action within a mapping, for how this and a few other examples are built look at the ODI 12c Aggregation Viewlet here - the viewlet illustrates a simple aggregation being built and then some Oracle analytic SQL such as AVG(EMP.SAL) OVER (PARTITION BY EMP.DEPTNO) built using both the aggregate component and the expression component. In 11g you used to just write the aggregate expression directly on the target, this made life easy for some cases, but it wan't a very obvious gesture plus had other drawbacks with ordering of transformations (agg before join/lookup. after set and so forth) and supporting analytic SQL for example - there are a lot of postings from creative folks working around this in 11g - anything from customizing KMs, to bypassing aggregation analysis in the ODI code generator. The aggregate component has a few interesting aspects. 1. Firstly and foremost it defines the attributes projected from it - ODI automatically will perform the grouping all you do is define the aggregation expressions for those columns aggregated. In 12c you can control this automatic grouping behavior so that you get the code you desire, so you can indicate that an attribute should not be included in the group by, that's what I did in the analytic SQL example using the aggregate component. 2. The component has a few other properties of interest; it has a HAVING clause and a manual group by clause. The HAVING clause includes a predicate used to filter rows resulting from the GROUP BY clause. Because it acts on the results of the GROUP BY clause, aggregation functions can be used in the HAVING clause predicate, in 11g the filter was overloaded and used for both having clause and filter clause, this is no longer the case. If a filter is after an aggregate, it is after the aggregate (not sometimes after, sometimes having).  3. The manual group by clause let's you use special database grouping grammar if you need to. For example Oracle has a wealth of highly specialized grouping capabilities for data warehousing such as the CUBE function. If you want to use specialized functions like that you can manually define the code here. The example below shows the use of a manual group from an example in the Oracle database data warehousing guide where the SUM aggregate function is used along with the CUBE function in the group by clause. The SQL I am trying to generate looks like the following from the data warehousing guide; SELECT channel_desc, calendar_month_desc, countries.country_iso_code,       TO_CHAR(SUM(amount_sold), '9,999,999,999') SALES$ FROM sales, customers, times, channels, countries WHERE sales.time_id=times.time_id AND sales.cust_id=customers.cust_id AND   sales.channel_id= channels.channel_id  AND customers.country_id = countries.country_id  AND channels.channel_desc IN   ('Direct Sales', 'Internet') AND times.calendar_month_desc IN   ('2000-09', '2000-10') AND countries.country_iso_code IN ('GB', 'US') GROUP BY CUBE(channel_desc, calendar_month_desc, countries.country_iso_code); I can capture the source datastores, the filters and joins using ODI's dataset (or as a traditional flow) which enables us to incrementally design the mapping and the aggregate component for the sum and group by as follows; In the above mapping you can see the joins and filters declared in ODI's dataset, allowing you to capture the relationships of the datastores required in an entity-relationship style just like ODI 11g. The mix of ODI's declarative design and the common flow design provides for a familiar design experience. The example below illustrates flow design (basic arbitrary ordering) - a table load where only the employees who have maximum commission are loaded into a target. The maximum commission is retrieved from the bonus datastore and there is a look using employees as the driving table and only those with maximum commission projected. Hopefully this has given you a taster for some of the new capabilities provided by the aggregate component in ODI 12c. In summary, the actions should be much more consistent in behavior and more easily discoverable for users, the use of the components in a flow graph also supports arbitrary designs and the tool (rather than the interface designer) takes care of the realization using ODI's knowledge modules. Interested to know if a deep dive into each component is interesting for folks. Any thoughts? 

    Read the article

  • Oracle : nouveaux licenciements en vue pour les employés de Sun en Europe et en Asie, est-ce une bon

    Mise à jour du 07/06/10 Oracle : nouveaux licenciements en vue pour les employés de Sun En Europe et en Asie : est-ce une bonne manière de relancer la société ? Oracle va à nouveau licencier parmi les quelques 106.000 employés de Sun. Les coupes vont concerner principalement les bureaux asiatiques et européens de la société. Le nombre de postes supprimés n'a pas encore été précisé par la firme de Larry Ellison, qui a racheté Sun en fin d'année dernière. Quelques indices ont cependant filtrés. D'après l'annonce d'Oracle, ce nouveau plan social devrait coûter deux fois plus que le précédent. Qui a, lui, concerné 7.600 emp...

    Read the article

  • ????????CSV???????(???????)?? ~ DBA????APEX

    - by Yuichi.Hayashi
    Oracle Application Express(Oracle APEX)????????????Web????????????????DBA??????·???????????????? ?????????CSV???????(???????)??·?? DBA???????????????????Oracle Database?????CSV????????????????? 1. ???Oracle APEX(Oracle Application Express)??????????????????????????????(???????????????SQL????????????????????????????????) 2. ???????????????????????(????????)??????????????????????? ?????????????????EMP???????? 3. ???????????????? 4.?????????????? ??????????????????????????????CSV???????????? ???????????? Oracle APEX?????????????????????????????????? APEX(Oracle Application Express)????~??????????????????????

    Read the article

  • jquery modal popup read from a file

    - by Hulk
    For the below code, there ia a form in the location /home/form.php .How can this form be opened with the below code.i.e, the modal dialog $dialog.html(data) .dialog({ autoOpen: true, position: ['right','bottom'] , title: 'Emp Form', draggable: false, width : 300, height : 400, resizable : false }); $dialog.dialog('open'); Thanks....

    Read the article

  • Copying contents of a model

    - by Hulk
    If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks..

    Read the article

  • Copying contents of a module

    - by Hulk
    If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks..

    Read the article

  • Oracle "Partition By" Keyword

    - by Nalandial
    Can someone please explain what the "partition by" keyword does and give a simple example of it in action, as well as why one would want to use it? I have a SQL query written by someone else and I'm trying to figure out what it does. An example of partition by: SELECT empno, deptno, COUNT(*) OVER (PARTITION BY deptno) DEPT_COUNT FROM emp The examples I've seen online seem a bit too in-depth. Thanks in advance!

    Read the article

  • Select count() max() Date HELP!!! mysql oracle

    - by DAVID
    Hi guys i have a table with shifts history along with emp ids im using this code to retrieve a list of employees and their total shifts by specifying the range to count from: SELECT ope_id, count(ope_id) FROM operator_shift WHERE ope_shift_date >=to_date( '01-MAR-10','dd-mon-yy') and ope_shift_date <= to_date('31-MAR-10','dd-mon-yy') GROUP BY OPE_ID which gives OPE_ID COUNT(OPE_ID) 1 14 2 7 3 6 4 6 5 2 6 5 7 2 8 1 9 2 10 4 10 rows selected. NOW how do i choose the employee with the highest no of shifts under the specified range date, please this is really important

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >