获取[Microsoft] [ODBC SQL Server驱动程序]可选功能未实现 [英] Getting [Microsoft][ODBC SQL Server Driver] Optional feature not implemented

查看:432
本文介绍了获取[Microsoft] [ODBC SQL Server驱动程序]可选功能未实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面提到的代码在MSAccess 2000中插入值,其中包含如下所述的表结构: -



字段名称数据类型



TodaysDate日期/时间

购物车识别号码

客户名称文字

活动文字

Team&细分文字

持续时间编号

磁带ID文字

开始日期日期/时间

结束日期日期/时间< br $>
电台文字



代码: -



I am using below mentioned code to insert values in MSAccess 2000 which having table structure as mentioned below:-

Field Name Data Type

TodaysDate Date/Time
Cart ID Number
Client Name Text
Campaign Text
Team & Segment Text
Duration Number
Tape ID Text
Start Date Date/Time
End Date Date/Time
Station Text

Code:-

private boolean enterDataIntoMSAccessDatabaseusingPreparedStatement()
    {
        try {

            ps = connection.prepareStatement("INSERT INTO Cart ID Details VALUES (?,?,?,?,?,?,?,?,?)");

            System.out.println("After Query");

        }

        catch (SQLException se) {

            generateErrorMessage("Error in Prepared Statement \n " + se.getMessage() );

            return false;

        }

        catch (Exception e)
        {
            generateErrorMessage("Unexpected Error Occured \n " + e.getMessage());
        }

        String todaysDate = cartIDApplicationAddCartIDDatejTextField.getText().trim();

        String cartID = cartIDApplicationAddCartIDCartIDjTextField.getText().trim();

        String clientName = cartIDApplicationAddCartIDClientNamejTextField.getText().trim();

        String campaign = cartIDApplicationAddCartIDCampaignjTextField.getText().trim();

        String teamSegment = cartIDApplicationAddCartIDTeamAndSegmentjTextField.getText().trim();

        String duration = cartIDApplicationAddCartIDDurationjTextField.getText().trim();

        String tapeID = cartIDApplicationAddCartIDTapeIDjTextField.getText().trim();

        String startDate = cartIDApplicationAddCartIDStartDatejTextField.getText().trim();

        String endDate = cartIDApplicationAddCartIDEndDatejTextField.getText().trim();

        String station = cartIDApplicationAddCartIDDELjCheckBox.getText().substring(0, 3);

        System.out.println(station);

        try {

            System.out.println("Before ps.setString()");

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.ENGLISH);

            System.out.println("Simple Date Format");

            /*ps.setString(1, todaysDate);
            ps.setString(2, cartID );
            ps.setString(3, clientName);
            ps.setString(4, teamSegment);
            ps.setString(5, duration);
            ps.setString(6, tapeID);
            ps.setString(7, startDate);
            ps.setString(8, endDate);*/

            System.out.println("1");

            ps.setDate(1, new java.sql.Date(simpleDateFormat.parse(todaysDate).getTime()));
            ps.setString(2, cartID);
            ps.setString(3, clientName);
            ps.setString(4, campaign);
            ps.setString(5, teamSegment);
            ps.setString(6, duration);
            ps.setString(7, tapeID);
            ps.setDate(8, new java.sql.Date(simpleDateFormat.parse(startDate).getTime()));
            ps.setDate(9, new java.sql.Date(simpleDateFormat.parse(endDate).getTime()));
            ps.setString(10, station);

            System.out.println("After ps.setString()");

            ps.executeUpdate();

       }
        catch (SQLException se) {

            generateErrorMessage("Error while inserting data in database \n " + se.getMessage());

            return false;
        }

        catch (Exception e)
        {
            generateErrorMessage("Unexpected Error Occured \n" + e.getMessage() );
        }

        return true;
    }







执行上述代码后我得到以下错误: -



[微软] [ODBC SQL Server驱动程序]可选功能未实现。



请帮助我。




I got below error after implementing the above code:-

[Microsoft][ODBC SQL Server Driver]Optional feature not implemented.

Kindly help me for the same.

推荐答案

我已经解决了这个问题,通过声明不同的变量,即用于创建SQL连接的Statement和Connection以及用于创建MS Access Connection的其他变量。



谢谢...... !!!
I have solved this problem, by declaring to different variable i.e. Statement & Connection for creating SQL Connection and other one for creating MS Access Connection.

Thank You...!!!


这篇关于获取[Microsoft] [ODBC SQL Server驱动程序]可选功能未实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆