<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":1171,"date":"2021-07-21T14:28:40","date_gmt":"2021-07-21T14:28:40","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=1171"},"modified":"2021-09-08T10:54:50","modified_gmt":"2021-09-08T10:54:50","slug":"how-to-connect-to-the-database-from-qtp","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/","title":{"rendered":"How to connect to the Database from QTP ?"},"content":{"rendered":"<div class=\"TextHeading\"><\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Create an ADODB connection object which is required step for connecting to database as below.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><strong><code id=\"code1\" class=\"hljs javascript\" data-lang=\"\"><span class=\"nt\"><span class=\"hljs-built_in\">Set<\/span> objConnection = CreateObject(\u201cADODB.Connection\u201c)<\/span><\/code><\/strong><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<div class=\"text-center row\" style=\"text-align: justify;\">\n<div class=\"col-sm-12\">Create Recordset object which is for getting a value from database.<\/div>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><code id=\"code2\" class=\"hljs javascript\" data-lang=\"\"><span class=\"nt\"><span class=\"hljs-built_in\"><strong>Set<\/strong><\/span><strong> objRecordSet = CreateObject(\u201cADODB.Recordset\u201c)<\/strong><\/span><\/code><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<p>Authentication using Id, Password and details.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Provider: For SQL server database the provider is \u201csqloledb\u201d<\/li>\n<li>Server: Open the SQL Server in your machine and Right click on the required Database\/ click on properties.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"ImageContent\" style=\"text-align: justify;\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png\" \/><\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Click on \u201cView connection Properties\u201d<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"ImageContent\" style=\"text-align: justify;\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-2.png\" \/><\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>User Name and Server details are required from this dialogue box<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"ImageContent\" style=\"text-align: justify;\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-3.png\" \/><\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>objConnection.open \u201cprovider=sqloledb; Server=SDWA-160-PC; User Id=SDWA-160; Password=; Database=sample; Trusted_Connection=Yes\u201d<\/li>\n<li>Hence, Connection setup completed and ready for execution.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Enter the required SQL query to be executed.<\/li>\n<li>Execution of the query with the statement below.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><strong><code id=\"code3\" class=\"hljs css\" data-lang=\"\"><span class=\"nt\"><span class=\"hljs-tag\">objRecordSet<\/span><span class=\"hljs-class\">.open<\/span> <span class=\"hljs-tag\">sqlQuery<\/span>, <span class=\"hljs-tag\">objConnection<\/span><\/span><\/code><\/strong><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-markdown code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markdown code-embed-code\">set conn=Createobject (&quot;ADODB.Connection&quot;) <br\/>Srvname=&quot;Driver={Microsoft ODBC for <br\/>Oracle}:Server=DBserver,UID=Sa,Password=sa&quot; <br\/>conn.open Srvname <br\/>Set Rec = Create Object(&quot;ADODB.Recordset&quot;) <br\/>SQL=&quot;select * from Users&quot; <br\/>Rec.open SQL ,conn <br\/>Username=Rec.fields(&quot;employee name&quot;) <br\/>Msgbox Username<\/code><\/pre> <\/div>\n<div class=\"Content\">\n<div class=\"hddn\">\n<ul>\n<li style=\"text-align: justify;\">The above mentioned sample script has been executed and the value from the database is retrieved.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : Create an ADODB connection object which is required step for connecting to database as below&#8230;.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[8518],"tags":[195,8541,8522,5937,203,199,214,289,363,209,5940,8534,8531,8519,8526,8536,8525,8537,8533,8532,205,8544,2936,5939,8543,8542,8521,8527,8530,8523,196,212,213,286,970,5938,8540,204,217,282,8520,8524,8528,288,4023,8545,206,200,8529,197,284,8539,280,364,8535,8538,15898],"class_list":["post-1171","post","type-post","status-publish","format-standard","hentry","category-qtp","tag-accenture-interview-questions-and-answers","tag-adodb-connection-in-qtp","tag-adodb-connection-in-qtp-for-excelexcel-connection-in-qtp","tag-aveva-software-interview-questions-and-answers","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-ciber-global-solutions-interview-questions-and-answers","tag-ciena-corporation-interview-questions-and-answers","tag-collabera-technologies-interview-questions-and-answers","tag-csg-international-interview-questions-and-answers","tag-database-automation-testing-using-qtp","tag-database-connection-in-qtp","tag-database-connection-in-qtp-using-dsn","tag-database-connection-in-qtp-with-sql-server","tag-database-connection-using-qtp","tag-database-connectivity-with-uft","tag-database-in-qtp","tag-database-testing-using-qtp","tag-db-connection-in-qtp","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-execute-statement-in-qtp","tag-fis-global-business-solutions-india-pvt-ltd-interview-questions-and-answers","tag-healthasyst-pvt-ltd-interview-questions-and-answers","tag-how-to-connect-to-database-in-qtp","tag-how-to-connect-to-oracle-database-using-qtp","tag-how-to-connect-to-oracle-database-using-uft","tag-how-to-connect-to-oracle-sql-developer-using-qtp","tag-how-to-connect-to-the-database-from-qtp","tag-how-to-fetch-data-from-database-in-qtp","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-infosys-technologies-interview-questions-and-answers","tag-lt-infotech-interview-questions-and-answers","tag-mindtree-interview-questions-and-answers","tag-newt-global-interview-questions-and-answers","tag-option-explicit-in-qtp","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-persistent-systems-interview-questions-and-answers","tag-qtp-database-script-examples","tag-qtp-database-testing","tag-qtp-sql-query","tag-r-systems-interview-questions-and-answers","tag-rbs-india-de-interview-questions-and-answers","tag-recordset-object-in-qtp","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-tech-mahindra-interview-questions-and-answers","tag-uft-connect-to-sql-server","tag-unitedhealth-group-interview-questions-and-answers","tag-valuelabs-interview-questions-and-answers","tag-virtual-object-in-qtp","tag-virtusa-consulting-services-pvt-ltd-interview-questions-and-answers","tag-wells-fargo-interview-questions-and-answers","tag-working-with-database-in-qtp","tag-working-with-excel-in-qtp","tag-xchanging-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to connect to the Database from QTP ? - QTP - Wikitechy<\/title>\n<meta name=\"description\" content=\"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to connect to the Database from QTP ? - QTP - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-21T14:28:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-08T10:54:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/\",\"name\":\"How to connect to the Database from QTP ? - QTP - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png\",\"datePublished\":\"2021-07-21T14:28:40+00:00\",\"dateModified\":\"2021-09-08T10:54:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage\",\"url\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png\",\"contentUrl\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to connect to the Database from QTP ? - QTP - Wikitechy","description":"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/","og_locale":"en_US","og_type":"article","og_title":"How to connect to the Database from QTP ? - QTP - Wikitechy","og_description":"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/","og_site_name":"Wikitechy","article_published_time":"2021-07-21T14:28:40+00:00","article_modified_time":"2021-09-08T10:54:50+00:00","og_image":[{"url":"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png"}],"author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/","name":"How to connect to the Database from QTP ? - QTP - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png","datePublished":"2021-07-21T14:28:40+00:00","dateModified":"2021-09-08T10:54:50+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"How to connect to the Database from QTP ? - Create an ADODB connection object which is required step for connecting to database as below.Set objConnection = CreateObject(\u201cADODB.Connection\u201c)","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp\/#primaryimage","url":"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png","contentUrl":"https:\/\/cdn.wikitechy.com\/interview-questions\/qtp\/how-to-connect-to-the-database-from-qtp-1.png"},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/1171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=1171"}],"version-history":[{"count":3,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/1171\/revisions"}],"predecessor-version":[{"id":3019,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/1171\/revisions\/3019"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=1171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=1171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=1171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}