Data Search In SQL Database

Hi, i want user to type a string in textbox, and i will search, if textbox.text exists in my SQL database table or not. Below is the code i'm using :---------------
 string txtname = (txtEmpName.Text).Trim();
 sQuery = "select * from tbUser where UserName='_username'";
 sQuery = sQuery.Replace("_username", txtname);
 SqlConnection objConnection = new SqlConnection(source);
 objDataAdapter = new SqlDataAdapter(sQuery,objConnection);
// DataTable dtTable = new DataTable();
 if (objConnection.State  == ConnectionState.Closed)
 objConnection.Open();
 objDataSet = new DataSet();
 objDataAdapter.Fill(objDataSet);
// objDataAdapter.Fill(dtTable);
or i want to search if "txtname" exists in "tbUser" table.
Thanks & Regards.
Manish S. Anand

This is a very poor coding, Unfortunately not fit anywhere :-(
This code is a security risk (sql injection)!
He should use SqlCommand class with parameters!
but yet if i understand the problem he is facing, then the problem is in the SQL part of the code and not the Dot.net :-) therefor it is fit to this forum. Basically the code should work, but as i understand from him his problem is in the
result set come back from the query filter. If so:
* the problem is that he use:
where UserName='_username'
instead of:
where UserName='%_username%'
and he do ask about the search problem :-)
[Personal Site] [Blog] [Facebook]

Similar Messages

  • JSP read and write data in MS-SQL database

    I am new to JSP. I need to write JSP page to read and write data in MS-SQL Database. I wonder if it is different from other database. I couldn't find useful pointers in the web. Please advise. Thanks!!

    Sure, SQL Server is different from Oracle is different from MySQL is different from...
    But all of them can be accessed using JDBC:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Maybe you should learn about that for starters.
    You can use SQL tags from JSTL in your JSPs. I'd recommend JSTL highly. No scriptlet code that way. - MOD

  • Transfering data from External SQL database to BW

    Hi Experts,
         I am trying to extract data from an External SQL Database  in BW using      
         DB Connect.
        1. I have created a  DB Source System.
        2. Using this Source System I have generated a Datasoure.
           ( following all the naming conventions for Table Names and Field Names)
        Till this point everything is OK.
        Then I assign a Infosource and try to upload the data into PSA.
        The process is never complete and I am getting a message
       <i> <b>Request still running
        Diagnosis
        No errors could be found. The current process has probably not finished yet.
        System response
        The ALE inbox of the SAP BW is identical to the ALE outbox of the source
        system
        and/or
        the maximum wait time for this request has not yet run out
        and/or
        the batch job in the source system has not yet ended.
        Current status
        No Idocs arrived from the source system</b>.</i>
         please help me.
      thanks
      arshad

    please first tell me which wich user you connect and the exact name of your table/view: is it dbo.table?
    as I said, better create a user in your SQL, log with this user and create a view.
    in RSBDC select this view and generate datasource. Check if you see data.
    if yes, the load shouldn't fail.
    We came across the same issue: login with sa, accessing a dbo. object; seing the data in RSDBC but nothing loading...
    let me know
    Olivier.

  • Is it possible to migrate WebCenter Portal data from a SQL database to an Oracle database?

    We have our WebCenter Portal applications set up using a SQL database. Now we're wanting to migrate to an Oracle database and I'm wondering if that is possible.

    Yes it should be possible though i have not tried it myself. You basically export a file from mds ( xml) and import it into oracle db.
    Thanks
    manish

  • Insert UK Date Into MS SQL Database

    Hi All..
    I'm using Dreamweaver 8.02, Classic ASP and MS SQL 2008
    I'm having problems inserting a UK formatted date from my form to my database.
    My form uses a standard text box for entering a date in the format of dd/mm/yyyy and inserts the a field in my db with a datatype of 'datetime', but when i submit the form, i get the error below!
    This is the insert line of code:
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 135, 1, -1, MM_IIF(Request.Form("expirydate"), Request.Form("expirydate"), null)) ' adDBTimeStamp
    I've tried all sorts of variations and i'm still unsure what the CONVERT function is (below)
    Any advise would be great
    Thanks in advance
    Andy
    Microsoft OLE DB Provider for SQL Server
    error '80040e14' 
    Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.

    setFloat takes a float primitive, not a Float object.
    select.setFloat( 4, theForm.getVaerdi().floatValue() );

  • Update a date field in SQL database

    I am using MS SQL 2000..and .Jdbc-odbc bridge
    I have a field of type datetime...
    I am trying to update that field value...using the following code
    rs.updateDate(fieldname,java.sql.Date.valueOf(fval));
    rs.updateRow();
    where fVal is a string...
    It gives me a SQl Exception saying invalid date value..
    Can any throw any light on this...helping me to overcome my error...

    This problem is solved...I am just inserting it as a string and the database takes care of everything...Now I have problems in inserting Integer value and a ntext value..
    rs.updateInt(colname,1);
    rs.updateRow();
    This inserts a very big number like 1427560 etc into the database and second time it puts 0 to it...
    For ntext it does not do anything
    smita

  • How to insert date/time to sql database

    Hi,
    I would like to insert date and time alongside with my data receiving from the sensor.
    Right now i can insert data into sql table everytime when the data changes but i also wanted to insert the date and time as well.
    Thank you in advance!

    I create a field that is a datetime and set the default value to getdate().  So everytime i make an entry into this database, it automatically adds a datestamp.

  • Reading/Writing Data from a SQL Database

    Hi,
    I have a data structure called 'Quote' which contains a number of different variables and controls ranging from text boxes, check boxes and radio buttons, i need to be able to read and write this from a database.
    First I think a description of my overall project is needed:
    Project Description
    I have been given a brief that basically says: i have to create a programmed solution in VB to solve a problem. This problem can be anything we like, and I personally have chosen to create a program that manages quotes for building Log Cabins (this is very contrived and far from anything someone would do in the real world).
    My solution will allow a generic user to create a quote (using a form with controls such as text boxes, check boxes, radio buttons) , and then save this to file. These users may then wish to load/edit this quote at a later date, from another form.
    Whilst completing this project, i'll only have up to about 5 records (quotes) within the system, so i dont need the ability to store hundreds of records. And each record will be relatively short, with only about 10-15 data items within the data structure.
    Also the Admin (or business owner in this case) need to be able to view all saved quotes in a presentable format, and edit them if needs be, from within this same program.
    This solution does not need to be absolutely perfect and 100% efficiently coded, or have all the bells and whistles a real-world program would have. This is for an A level computing project by the way.
    So basically, i need to be able to read from the database (to populate a Data Grid (i imagine this is best way?)) and so Admin can access any quote and edit it (editing is not vital, but viewing/printing is. Maybe i should stop at just viewing any quote?). Also i need generic users to be able to fill in the Edit Quote form and then save this data into the database.
    And is a data structure really required for me to use a database?
    I've never used databases in VB before (but have used them elsewhere, mainly Access) and so am completely new to this. Any help will be much appreciated.
    Thanks

    this is just a dataset i created using the dataset designer.
    OK, so i have the dataset called "MyDataSet".
    I also have the following variables:
    Code Snippet
    Dim FloorSpace As Int32
    Dim NoOfBedrooms As Int32
    Dim NoOfBathrooms As Int32
    Dim EnSuites As Int32
    Dim LuxKitchen As Boolean
    Dim LuxCabin As Boolean
    Dim Flooring As Boolean
    Dim VoiceLighting As Boolean
    Dim SolarPanels As Boolean
    Dim IntegralSound As Boolean
    Dim WindowFrames As String
    Each of which relates directly to a column in the dataset (data type matches too).
    What i need to do now, is to save these variables as an additional record in MyDataSet. And then save MyDataSet to file, so it can be loaded again next time the program is run and more additional records added. (all files are local by the way).
    how would i go about this?

  • How to configure SharePoint 2010 / 2013 Search for SQL Database Contents and Oracle Database Contents?

    Hi All,
    We are planning to maintain the contents in SQL / Oracle. Could you please suggest anyone which is best for SharePoint 2010 / 2013 Search. How to configure the search for external content source?
    Thanks & Regards,
    Prakash

    This link explains supported and non supported scenarios to use Oracle for BCS
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/453a3a05-bc50-45d0-8be8-cbb4e7fe7027/oracle-db-as-external-content-type-in-sharepoint-2013
    And here is more on it
    http://msdn.microsoft.com/en-us/library/ff464424%28office.14%29.aspx 
    And here how you can connect Oracle to SharePoint for BCS functionality
    http://lightningtools.com/bcs/business-connectivity-services-in-sharepoint-2013-and-oracle-using-meta-man/
    Overall it seems SQL doenn't require any special arrangement to connect BCS to SharePoint.
    Regards,
    Pratik Vyas | SharePoint Consultant |
    http://sharepointpratik.blogspot.com
    Posting is provided AS IS with no warranties, and confers no rights
    Please remember to click Mark As Answer if a post solves your problem or
    Vote As Helpful if it was useful.

  • Database Toolkit: Reading data from SQL database

    Hello,
    I have been working on a automated test system storing data into a SQL server database.  Once you get your head wrapped around the toolkit and walk through some of the examples it is not too bad.  Writing to the database was very straight forward.  I simply put all of my data including the primary keys into a cluster and inserted the cluster into the specified table.  As I learned the hard way,  it is very important for all of your types to match up.  I saved double type from labview as decimal type in the SQL database, and long integer in labview as integer in the SQL database. 
    For the the read VI, this is where my questions lie. After establishing a connection reference I used the "DB Tools Create Parameterized Query" VI combined with a SQL statement to find the recordset that I was looking for.  I used a standard SQL statement using the primary keys such as, "Select * From TableName Where Measurements = "%Measurements%" ".  This VI creates a command reference which I then passed to multiple "DB Tools Get Parameter Value" VIs.  I could not get this to work with the command reference. 
    I then switched over to the "DB Tools Execute Query" inputting the same SQL statement I had used before.  THis VI passed a recordset reference, which I then passed to a "DB Tools Get Properties" VI to check if the database was empty or not.  I then passed the recordset reference to multiple "DB Tools Fetch Element Data"  VI's to read the data from the SQL database.  THis worked very well. 
    therefore I am wondering:
    What is the difference between a command reference and a recordset reference in the Database connectivity toolkit? 
    Why would one work and not the other? 
    Is there ever a case when you would want to use one method over the other? 
    I have asked my app guys and Labview training instructor different database type questions, and I not received a decent answer to date.
    Thanks,
    Jackson

    Hello,
    Can you pass the command reference to a single "DB Tools Get Parameter Value" VI?  What exactly do you mean when you say you couldn't get this to work with command references... can you post an error message or the results?  The documented difference is that they are different flavors of ADOs (activeX data objects), one is a command and the other is a recordset reference.  I know this does not draw a precise distinction, but I'd like to understand this problem fully so we can find one!
    Please repost with anything more you can give!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Merge to Insert or update records in SQL Database

    Hello ,
    I am having hard time with creating a Stored Procedure to insert/update the selected records from Oracle data base to SQL database using BizTalk.
    ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
    @dp_id char(32),
    @dv_id char(32),
    @em_number char(12),
    @email varchar(50),
    @emergency_relation char(32),
    @option1 char(16),
    @status char(20),
    @em_id char(35),
    @em_title varchar(64),
    @date_hired datetime
    AS
    BEGIN
    SET NOCOUNT ON;
    MERGE [dbo].[em] AS [Targ]
    USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
    AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
    ON [Targ].em_id = [Sourc].em_id
    WHEN MATCHED THEN
    UPDATE SET dp_id = [Sourc].dp_id,
    dv_id = [Sourc].dv_id,
    em_number = [Sourc].em_number,
    email = [Sourc].email,
    emergency_relation = [Sourc].emergency_relation,
    option1 = [Sourc].option1,
    status = [Sourc].status,
    em_title = [Sourc].em_title,
    date_hired = [Sourc].date_hired
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
    VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
    END;
    I am getting an error like
    WcfSendPort_SqlAdapterBinding_
    TypedProcedures_dbo_Custom" with URL "mssql://abc//def?". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.Data.SqlClient.SqlException (0x80131904): Procedure or function 'uspInsertorUpdateINF'
    expects parameter '@dp_id', which was not supplied
    I cannot give the Oracle Database name directly in the stored Procedure
    I am stuck with this, and cannot figure out since I am new to SQL Queries and Stored Procedures. Any help is greatly appreciated.
    Thanks

    Hi sid_siv,
    Only the first record is inserted because of the scalar variables of the stored procedure(SP), when you call the SP, only one row is passed. To get all rows inserted, you can either declare a
    table-valued parameter
    (TVP) for the SP or using an Oracle linked server in the SP.
    Create a stored procedure with a table-valued parameter
    As you mentioned linked server is not good in your case, then TVP SP can be the only option. Regarding how to call a SP with TVP parameter in BizTalk, that's a typically BizTalk question then. I would suggest you post your question in a dedicated
    BizTalk Server forum. It is more appropriate and more experts will assist you.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How to save ICM data to an SQL DB

    Hello,
    I know it is possible in UCCE to retrieve SQL data to use in ICM routing, but is there a way to store ICM data into an SQL database in order that other applications can retrieve that data?
    Here's what we're trying to accomplish. We would like an ICM script to collect data from a caller using the IVR to actually collect the data then have ICM store that into temporary variables. We would then like ICM to store those temp vars into an SQL database so that another app can look at that table for that data and populate it's screens.
    Is this possible?
    We are running UCCE 7.1(5) with CRS (IVR) 4.0(5)
    We have IVR scripts to collect the data and ICM scripts to store this collected data into ICM variables, but now I need to know how to store them into an SQL table.
    Any help with this will greatly be appreciated.
    Thanks,
    Joe Mattia

    David,
    that is exactly what I was hoping to hear. Thanks.
    I've spent the most part of today working with a test IVR script to accomplish the simple task of saving to an SQL DB and I'm getting there slowly.
    I created a test SQL DB, configured the database subsystem on the IVR server, used the Get Digit String command to prompt the user to enter a customer number, then used the DB Read followed by DB Write to save that value into a DB field. I was successfull in saving a forced value, but now I'll try saving the user's input and see how that goes.
    The first time I tested this, it saved the value, but any time after that, it didn't work and now I can't even open up that SQL table. It appears to be locked.
    I also think I didn't set up a proper primary key on the test DB, that could be causing this issue as well.
    Do you happen to have an example of this type of IVR script?

  • Access Report Link to SQL database

    Hi,
    I have been designing a report interface in Access that is supposed to retrieve data from an SQL Database. The problem is that i don't know how to connect the two so that it (report) retrieves data from the database. How do I connect the two?
    martin

    Hi breakage,
    Based on my understanding, you want to connect to a SQL Server database on Access side, then retrieve the data from the database.
    When connecting to a SQL Server database, Access creates a new table (linked table), and it's structure and contents are corresponding to the source object. In your scenario, you can open the Access database in which you want to create the linked tables,
    then choose External Data tab. With the wizard, you can link the expected SQL Server database. For more information, please refer to the
    Link to SQL Server data section of this article:
    Import or link Access to SQL Server data .     
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Connecting SAP with an independent SQL database

    Dear all,
    I need to connect SAP with an independent MSSQL database.
    My requirement is to transfer a set of records from my Ztable to a table in SQL database.
    I have maintained the settings in DBCO transaction. I maintained DBMS as 'MSS' in DBCO.
    send some sample code of how to establish the connection. Is it possible to write data in to SQL database.
    How to edit the file tnsnames.ora in application server directories. I heard that for connecting to an oracle database we need to edit this , is it necessary to edit this tnsnames.ora even for connecting with SQL database?
    Thanks in advance.
    Lakshman

    This is not possible.
    My suggestion is that you create shell scripts on the unix side that copy the data to the other database.
    ARD runs it's own private copy of PostGgreSQL inside the package so it won't interfer with any other SQL databases on the network or even on the machine.

  • BSP to query Sql database?

    Just curious to find out if this is an option..
    We web AS 6.40, can we write in ABAP to query data from a SQL database?
    Thanks in advance..
    Vince

    Yes.
    if you can eloborate little more on what you are trying to do, we can be helpful.
    Regards
    Raja

Maybe you are looking for

  • Re: HP All-in-one Remote app and HP 4620

    Hi I already have a HP B110a printer and have just bought an Officejet 7610 as I wanted A3 scanning and printing. I was using the old HP Printer Control app with my iPad 1 but I cannot get the app to see the new 7610 printer. It is definitely connect

  • Error while setting up Weblogic Portal(10.3.6) db connection

    HI All, I am a newbie to Weblogic Portal so kindly correct me if im wrong anywhere... I am trying to set up a new instance for Weblogic Portal 10.3.6 While setting up a new domain i got the error below: CFGFWK-60850:  Test Failed! Later wheni tried r

  • Report Painter - New Characteristics in General Selection

    Hi, I'm trying to modify a custom FI report (that uses CCSS reporting table) by adding additional characteristic fields into its general data selection. So far i've added these ZZ fields into CCR1S, and activated characteristics in library. I can see

  • Tables storing GL accounts for Balnce sheet report

    hi experts, pls let me know what all are the tables used for storing GL accounts.i need to prepare a balance sheet report using those tables..

  • Customer reports-Table and field required

    Hi experts, We have customized on customer reports.We raise billing in USD4,in INR and in other currency.At present,they can get reports in INR,USD4 and other currency separately.Now my user requires,the whole reports in USD4,that means all other cur