SQL connection string reader Date time data type format

I am using below script to fetch data fields from DB. Script runs fine but at the end receiving following error as 
Exception calling "GetDateTime" with "1" argument(s): "Specified cast is not valid."
At line:6 char:36
+     $termdate = $reader.GetDateTime <<<< (23)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
$sqlconstr = 'Data Source=Server;Initial Catalog=DB;User ID=User;pwd=$XXXX;'
$sqlconn = New-Object system.Data.SqlClient.SqlConnection
$sqlconn.connectionstring = $sqlconstr
$sqlconn.open()
$sqlquery1 = "SELECT * from TERMDB" 
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand ($sqlquery1,$SqlConn)
$reader=$sqlcmd.ExecuteReader()
    while ($reader.read())
        $emp = $reader.GetString(0)
        $fn = $reader.GetString(3)
        $ln = $reader.GetString(5)
$termdate = $reader.GetDate(24)
"$emp,$fn,$ln,$termdate" | out-file -FilePath "C:\testing1.txt" –append
$sqlconn.close()
        Please help with the data type required for Date time.

Thanks.
When i run syntax i gets below error.
$conn = New-Object system.Data.SqlClient.SqlConnection
$conn.connectionstring='Data Source=Server;Initial Catalog=DB;User ID=User;pwd=$XXXX;'
$conn.open()
PS X:\> $cmd=$conn.CreateCommmand()
Method invocation failed because [System.Data.SqlClient.SqlConnection] doesn't contain a method named 'CreateCommmand'.
At line:1 char:26
+ $cmd=$conn.CreateCommmand <<<< ()
    + CategoryInfo          : InvalidOperation: (CreateCommmand:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
I will mark it as Answered & open new thread for AD cmdlet.

Similar Messages

  • Creating Web service for PL/SQL Procedure with Complex Data Types

    I need to created web service for PL/SQL Procedure with Complex Data types like table of records as parameters, how do we map the pl/sql table type parameters with web service, how to go about these?

    Hello,
    When you are creating a service from a Stored Procedure, the OracleAS WS tools will create necessary Java and PL wrapper code to handle the complex types (table of record) properly and make them compatible with XML format for SOAP messages.
    So what you should do is to use JDeveloper or WSA command line, to create a service from your store procedure and you will see that most of the work will be done for you.
    You can find more information in the:
    - Developing Web Services that Expose Database Resources
    chapter of the Web Service Developer's guide.
    Regards
    Tugdual Grall

  • SCOM 2012 - SQL Connection strings

    Hey SCOM gurus
    Wonder if you can help?
    I need to change my SCOM 2012 Management Server 'SQL Connection strings' to use a load balancer dns name of 'sql-listener'. Can anyone suggest how this might be done? (basically we now have a SQL 2014 Cluster in the background).
    thanks
    Karen

    Hello,
    You must change the database name in the registry, more information : https://technet.microsoft.com/en-us/library/hh278848.aspx?f=255&MSPPError=-2147217396

  • Conversion from a string to date type

    I am trying for a servlet application , for which the requirement is as under :
    from a html form through a input type text field , a date in string format , say 12/25/01 , is picked up.
    this date is received in the servlet code , and is required to be updated in Microsoft Access Database Table under a field of data type "Date/Time"
    here the problem is , the date's existing data type is String and the Access' field's Data type is Date/Time , therefore, it needs to be suitably converted to a date format before it is put into a sql statement .
    please help , if any functionality is available for a conversion .
    thanx and regards

    yes stephen , taking a tip from you and another from a post from this forum yesterday on SQL Exception , i shifted my focus to java.sql.Date ,
    now modifying my code as under works with perfect perfection ,
    thanks stephen and joe schell for all the help
    kapil
    import java.text.*;
    import java.sql.Date;
    import java.sql.*;
    class HardTrial{
         public static void main(String args[]){
              Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
              Date d = new Date(123456789);// initialising with some value
              Date d1 = d.valueOf("1994-12-12");
              try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con = DriverManager.getConnection("jdbc:odbc:STUDENT_DSN");
              stmt= con.createStatement();
         PreparedStatement ps = con.prepareStatement("INSERT INTO NewTab VALUES (?,?)");
         ps.setDate(1, d1);
    ps.setString(2, "TESTING");
    ps.executeUpdate();
         rs = stmt.executeQuery("SELECT WHEN,WHAT FROM NewTab");
         while (rs.next()){
         System.out.println(rs.getString("WHEN")+ rs.getString("WHAT"));
         }catch(Exception e){
              System.out.println(e);

  • Function returning string.  Data type question

    Hello all,
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Our database has a parent record master_member_record_id & and children of those records member_record_id. I wrote a function which returns the master record for the child.
    eg. get_master(member_record_id). simple enough.
    I have wrote the opposite of this also, get_member_records(master_member_record_id). Obviously this function has multiple records to return so I have it set to return a listagg string with ',' separation. They want to be able to use this function as follows:
    select * from member_table where member_record_id in (get_member_records(master_member_record_id));
    or something similar, I realize this is a data type issue here, wondering if this is even possible. What do you think?
    Thanks in advance for your criticism/help,
    Chris

    My disagreement is with how pipeline table functionality is used.
    Instead of this (what it sounds like the OP is doing but returning CSV format)
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray is
      array TClientIdArray;
    begin
      select
        client_id bulk collect into array
      from master_table
      where parent_id = parentID;
      return( array );
    end;A pipeline would look as follows:
    create or replace type TClientIdArray is table of number;
    create or replace function GetClientIDs( parentID number ) return TClientIdArray pipelined is
    begin
      for c in (select
                   client_id
                 from master_table
                 where parent_id = parentID ) loop
        pipe row( c.client_id );
      end loop;
      return;
    end;The first method is in fact more sensible in this case, especially when used from PL/SQL. A single SQL call/context switch to get a list of client identifiers. The issues with the first method are
    - cannot effectively deal with a large data set of client identifiers
    - would be suboptimal to use this function in subsequent SQL
    - if called by a client, a ref cursor (not collection) should be returned
    But assuming that the list of client identifiers are needed to be stepped through via complex PL/SQL app processing, using a (small) array is fine (assuming that concurrency/locking is not needed via a FOR UPDATE on the select that identifies the client identifiers to process).
    A pipeline in this case does not do anything better. It introduces more moving parts - as a native PL/SQL can no longer be used to get the collection and step through it. A TABLE() SQL function is needed, a SQL statement, and more context switching.
    The pipeline is simply an unnecessary layer between the code wanting to use the client identifiers and the SQL statement supplying the client identifiers. This approach of SQL -calls-> PIPELINE -calls-> MORE SQL is invariable wrong - unless the pipeline (PL/SQL code) does something very funky with the data from its SQL call, prior to piping it, that cannot be done using SQL.
    If the "user" of that client identifiers is SQL code, then both the above methods are flawed. As this code is already SQL, why use PL/SQL to call more SQL code? Simply use the SQL code/logic that supplies the client identifier list directly in the SQL code that needs the client identifiers. This means something like SQL JOIN, EXISTS, or IN clauses.

  • Change "String" into data type "Date"

    Hi,
    I have created a report containing several date fields for a plan/actual comparison. The connection is built up by using the jdbc connector.
    My problem is that the date fields are only displayed as String, but I actually want them to be displayed as Date type.
    Here an example:
    Right now the date fields are displayed like this "20060411"
    but I want them to be displayed like this ("11/04/2006", or similar).
    I would appreciate any suggestions to solve this problem!
    Cheers
    Thomas

    Hi Thomas,
    Check out the following links :
    http://help.sap.com/saphelp_nw04/helpdata/en/55/55a34098022a54e10000000a1550b0/content.htm
    http://help.sap.com/download/netweaver/nw04/visualcomposer/VC_60_UserGuide_v1_1.pdf
    Re: Custom message in VC
    Thanks in advance,
    Deep.

  • Error when insert data in Sql Server table(DateTime data type)

    Hello all,
    I have created a database link in oracle 11g to SQL Server 2008 using Sqlserver gateway for oracle,Oracle run on Linux and SQL Server run on Windows platform.
    I have queried a table and it fetches rows from the target table.
    I am using this syntax for insert a row in Sql Server table.
    Insert into Prod@sqlserver (NUMITEMCODE, NUMPREOPENSTOCK, NUMQNTY, NUMNEWOPENSTOCK, DATPRODDATE , TXTCOMPANYCODE, "bolstatus", NUMRESQNTY )
    Values (1118 , 1390.0 , 100.0 ,1490 , '2012-06-23 12:37:58.000','SFP' ,0 , 0 );
    but it give me error on DATPRODDATE,The data type of DATPRODDATE column in Sql Server is DATETIME.
    My Question is how can i pass the date values in INSERT statement for Sql Server DateTime data type.
    Regards

    Just as with Oracle, you have to specify the date using the to_date() function or use the native date format for the target database (if you can figure out what that is). This is good practice anyway and a good habit to get into.

  • Is string primitive data type?

    - Is String a primitive date type? Elaborate please.
    - How is String object is mutable?

    > It is completely immutable. Once created it cannot be changed.
    import java.lang.reflect.*;
    public class ImmutableStringDemo {
        public static void main(String[] args) throws Exception {
            String string = "foo";
            System.out.println(string);
            new StringChanger().change(string);
            System.out.println(string);
    class StringChanger {
        public void change(String s) throws IllegalAccessException {
            Field[] fields = s.getClass().getDeclaredFields();
            for (Field f : fields) {
                f.setAccessible(true);
                if (f.getType() == char[].class) {
                    f.set(s, "bar".toCharArray());
    }QED. ;o)
    ~

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Report Designer odbc connection string for data source using a parameter

    I am using stand alone report designer 3 for the present and have a question/problem regarding the odbc connection string for MySQL when setting up the data-source
    I need to be able to enter a parameter which is the database name i.e. BOE-201401 or say BOE-201312 etc  from a list of databases the user can choose from.
    at present the odbc connection string points to BOE-201402
    the connection string is at present  Dsn=Development Server for MYsql;description=MYSQL;server=ldndw01;database=BOE-201402;port=3306
    my parameter has the name BOE_DATABASE
    and in an expression it is  as such
    =Parameters!BOE_DATABASE.Value
    I want to point the datasource for the report to the parameter value before the user sees the report.

    Hi Leslie,
    Based on your description, we want to design a report with a dynamic DataSource connection string. There are the basic steps below for your reference:
    Create report with static database.
    Change data source to report parameter.
    Send new database connection string as a report parameter. 
    More detail information, please refer to the following blog: Dynamic Database in SSRS 2008.
    http://haseebmukhtar.wordpress.com/2011/11/09/dynamic-database-in-ssrs-2008/
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Read Data Type Structure

    Hi,
    Is it possible using ABAP to read the schema definition of a data type to provide a list of the elements defined.
    Thanks
    Martin

    Hi,
    In ABAP you can parse xml or xsd using iXML package. Search for that in SDN.
    The Message Interface will surely have the Message type name. So your requirement is absolutely possuble.
    Need to know in which scenario you will use this? Please post that.
    Regards,
    P.Venkat

  • SQL Developer Migration Workbench - Data Type Mappings

    Hi,
    Using SQL Developer 1.1.3.2766 to migrate a MySQL 4.1.22 database.
    How do I change a system defined data type mapping? I would like to map "text" data type to "varchar2". This is something I could do in OMWB.
    I can create a new rule but cannot delete the system defined "text" rule.
    thanks,
    Greg

    Greg,
    You cannot delete the system default rules, but if you create your own, these will take preference during the convert phase. Is this not the case?
    Donal

  • Try to use dynamic sql connection for additioal data for xml publisher

    I understand that the xml publisher is using template to merger the xml data output (say from Oracle report).
    We have some Oracle seeded report and do not wish to modify these report, but we do need to add additional data to these reports. In the past, the tool we used has the capability to make dynamic sql calls to get these additional data. Can this be achieved in xml publisher?
    I did noticed that the template builder has two options for upload data source: from a data file or from a sql connection, but seems they can not be used together. Not much document I can find for this. Thank you in advance for your help.
    Frank

    Hi All,
    Sandeep: if u have the solution pls send to my email id [email protected]
    ill really appriciate u r response.
    I have the same requirement to develop AR Invoice Report in XML publisher, actually it was developed using Optio Layout.my issue is the actual AR Invoice RDF contains 20 records and it showing the 20 recodes when we run that program (concurrent program output) after that while printing this report uisng the OPTIO layout (The Optio system is fetching some more records (10 records)) it printing total 30 records. i mean here the OPTIO is handling some pl/sql code i guess..
    so now how we can handle this requirement using XMLP.I am using RTF Templates with 5.6.2 v. Is it possible to do the same manner how the OPTIO was doing. Is this possible with any other Templates ?. or we need to customize the RDF itself ? .but I know that I can go ahead and modify the existing out-of-the-box report, but I do not want to do that. I do not have control over the XML that is generated since the XML is generated when the report is run. Is there any way to retrieve the extra information AFTER the xml has been generated and BEFORE the template is applied ?
    Thanks,
    Rad

  • How to read *.dat type file

    Hallo!
    Can anyone help me with reading *.dat file using labview functions. Previously I've read them via matlab script, but after compiling to executable I could not read *.dat files. It might be because I'm working on LV 6i and in order to be able to read via matlab 6.5 I've paste matlabscript.dll from LV 7 to the main 6i place. However now I want to load this dats by using LV function and I can not achieve it.
    I've already tried to use some examples from the help base and it doesn't work. There are slightly more then 2 milion samples in one coloumn in tis file.
    Can anyone show me how to do that? I will appraciate
    thanks
    michal m
    Attachments:
    260701-1405V1.zip ‏1 KB

    LabVIEw is always big endian (on any platform), but most other programs are little endian on intel machines (windows). See also the link Donald posted.
    Your particular code still has a few bugs. Since you are reading U16, the number of data points is half the number of bytes in the file. You are trying to read twice as many and always get Error 4 (EOF encountered). To avoid this error, you need to divide the bytes by two for reading. Also watch out for correct representations, your record(s) indicator is I32 instead of U16, causing unecessary extra memory usage. ... and don't forget to close your file when done reading.
    Message Edited by altenbach on 05-30-2005 09:19 AM
    Message Edited by Support on 05-31-2005 08:59 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ReadU16Dat.png ‏6 KB

  • How to create SQL Connections String using JSP

    Hi, Dear I wrote sample Jsp program(Create a table and Inserted to Table) using SQLConnection
    I got this Error, how to rectify please help me?
    This is my Connection String
    <%
    String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
         Class.forName(driver).newInstance();
         Connection con=null;
         ResultSet rst=null;
         Statement stmt=null;
         try
              String url=java.sql.DriverManager.getConnection("jdbc:sqlserver://10.1.5.6:1433;Database=manickaraj;User=sa; Password=test*");
              con=DriverManager.getConnection(url);
              stmt=con.createStatement();
         catch(Exception e)
    System.out.println(e.getMessage());
         if(request.getParameter("action") != null)
              String CategoryName=request.getParameter("Category1");
              String Description=request.getParameter("Description1");
    String Status=request.getParameter("Status1");
              stmt.executeUpdate("insert into Category(CategoryName,Description) values('"+CategoryName+"','"+Description+"','"+Status+"')");
              rst=stmt.executeQuery("select * from Category");
    %>
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 5 in the jsp file: /CategoryAction.jsp
    Generated servlet error:
    C:\Documents and Settings\manickaraj\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\SampleJsp\org\apache\jsp\CategoryAction_jsp.java:61: incompatible types
    found : java.sql.Connection
    required: java.lang.String
    An error occurred at line: 5 in the jsp file: /CategoryAction.jsp
    Generated servlet error:
              String url=java.sql.DriverManager.getConnection("jdbc:sqlserver://10.1.2.4:1433;Database=manickaraj;User=sa; Password=test*");
              ^
    1 error
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

    package shop;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    public class DAClass {
         private static Connection conn;
         private static ResultSet rs;
         private static PreparedStatement ps;
         public static void connect(String dsn, String un, String pwd) {
              try {
                   //access or Mysql odbc connectivity
                   //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   //conn=DriverManager.getConnection("jdbc:odbc:"+dsn,un,pwd);
                   //mysql
                   //Class.forName("com.mysql.jdbc.Driver");
                   //conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/eshop?user=root&password=root");
                InitialContext ctx = new InitialContext();
         DataSource ds = (DataSource) ctx.lookup("jdbc/eshop");
          conn = ds.getConnection();
         //DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MySQLDB")
              catch(Exception e) {
                   //return "not soory";
         public static boolean chkPwd(String un, String pwd) {
              try {
                   boolean b=false;
                   ps=conn.prepareStatement("select * from cust_info where cust_name=? and cust_pwd=?");               
                   ps.setString(1,un);
                   ps.setString(2,pwd);
                   rs=ps.executeQuery();
                   while(rs.next()) {
                        b=true;
                   return b;
              catch(Exception e) {
                   return false;
    }changed the code like this other part is same.implemented connection pooling but still its too lazy loding can you guide me?

Maybe you are looking for

  • Do i need to back up applications with time machine?

    I received a message that Time Machine was running out of room to back up. I've only used 112GB on my computer, but my Time Machine drive has a capacity of 163GB, so I don't understand why I am running out of room. Do I need to back up my application

  • Doubt in Query(on 28th)

    Hi all I wrote the following query SELECT COUNT(DISTINCT QUESTION_ID) AS QCOUNT, DECODE(((SUM(SUM(WORK_SPACE))/5)*100)/QCOUNT,<50,COUNT(DISTINCT RESPONSER_ID)) AS COUNT1, DECODE(((SUM(SUM(WORK_SPACE))/5)*100)/QCOUNT,>=50 AND <=60,COUNT(DISTINCT RESPO

  • SQL Server jobs fail if I signout the Remote Desktop connection

    I have some SSIS jobs running in the production server which we usually take that server by Windows' Remote Desktop Connection to monitor the jobs. The problem in our case is If we sign out the server in remote connection, all the sql server jobs get

  • Guitar Rig 5 MIDI controls won't stay mapped in Mainstage 2

    I am using Guitar Rig 5 as a plug-in in Mainstage 2 for a few of it's effects.  I am trying to map controls (like on/off) for those effects in Mainstage's mapping section.  Everything works fine until I close mainstage.  When I go to reopen my saved

  • SDATA EMPTY FIELD

    HY yall , i having an issue with my inbound custom idoc with data coming from AMM thru SAP-PI. when one field of a segment is empty, the field is not transmitted in the segment therefor all the wa in witch i do a move-corresponding is complety false.