Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all 1350 articles
Browse latest View live

SELECT WITH POSTGRE ASCII / FILL DATATABLE - 22021: invalid byte sequence for encoding \"UTF8\": 0xaa

$
0
0

Hello guys

I have an urgent case here.

I am trying to perform a select on a table in the postgre database of a client, however this database is not in UTF8 but in SQL_ASCII

So when I run the ".fill" in my dataadapter / datatable, this message appears:

22021: invalid byte sequence for encoding \ "UTF8 \": 0xaa

Any idea?


Select Query to show same value in all rows matching specific condition

$
0
0

hi,

I have a table with data in following structure:

CallNumber|Duration1112301112null1112null1119101175null1132591175190

I want result of select query as:

CallNumber|Duration11123011123011123011191011751901132591175190

I do not know how to achieve the above result I am using MySQL database.

OleDB Error in IIS hosted web site - while after installed KB4034660 - An unhandled win32 exception occured in w3wp.exe[11108]

$
0
0

Hi All,

I have created a simple web site using .NET Framework 4.0 and Visual Studio 2010. It was worked fine till before installed the recent August-windows updates(KB4034660).

I have deployed the web site in my local IIS, and it is worked very well till the KB4034660 is installed.

I am getting the below error, while after the KB is installed. I have tried by uninstalled the KB batch and after that the website is works very well in both VS2010 debug mode and IIS hosted web site.

Error:

An unhandled win32 exception occured in w3wp.exe[11108]

The Just-In-Time debugger was launched without necessary security permissions.

And i have found an error is occurred on opening the oledbconnection by calling the statement _OledbConnectionInstance.Open();

In some time while on calling the below fill statement.

_OleDbDataAdapterInstance.Fill(myDatasetInstance);

An unhandled win32 exception occured in w3wp.exe[11108]

Please provide the your valuable solution to fix the error. Thanks in advance.


S.ARUL JOTHI

Move from Windows Server 2008 to 2012 and ORAOLEDB.ORACLE just hangs

$
0
0

Hi

I've a VB.net application which connection to an Oracle DB via ORAOLEDB.ORACLE.

It works fine on one server (which is Windows Server 2008) and we wish to move it to Windows Server 2012.

The application just hangs at this point (in bold) ...

Public Function QueryOracleDB(ByVal TheSQLQuery As String, ByRef ErrorMessage As String, ByRef TheResults As String) As Integer
            Dim ConnectionString As String = ConfigurationSettings.AppSettings("IFSConnectionString")
            Try               Dim myConnection As New OleDbConnection(ConnectionString)
             Dim myCommand As New OleDbCommand(TheSQLQuery, myConnection)
              myConnection.Open()

The query string is ...

Provider=ORAOLEDB.ORACLE;User ID=theid;password=thepassword;Data Source=E123

If I change the 'Provider' it will give me an error naturally ...

The 'ORAOLEDB.ORACLEs' provider is not registered on the local machine.

However if I give it the correct provider but an incorrect password for the Oracle DB it says nothing. Just hangs.

Thanks

p

How to update a cell A1 in csv/xls & then get B1 value to Label1.Text ?

$
0
0

I wish on buttonclick update cell A1 value in csv or xls with Label2.Text say 100
and then let that csv/xls B1 which has a forumla =A1*20 to compute a new B1 value to be 2000 (100*20)

Then I wish to get back the value of cell B1 (2000 after calc) to Label1.Text on the same page....
It is ok that csv/xls to either a file on web server or on client machine.

How to do this ?

Thanks

odp.net wrong number or types of arguments in call

$
0
0

All,

  We've upgraded our website to VS2015 and using ODP.net which uses the Oracle 4.0 dll.  I'm getting an error with wrong number of types of arguments and everything looks fine. I'm hoping someone here can see my code below and figure out what's wrong.

DB:

TYPE T_CURSOR IS REF CURSOR;

PROCEDURE GET_REQUESTS_SRCH (P_USR_ID_NUM IN REQUEST.REQUESTOR_ID%TYPE,

        P_ROLE_NAME IN VARCHAR,

       P_REQUEST_ID IN REQUEST.REQ_ID%TYPE,

                            P_REQ_TITLE IN REQUEST.REQ_TITLE%TYPE,

                            P_STARTDATE IN VARCHAR,

                            P_ENDDATE IN VARCHAR,

                            P_REQUESTOR_ID IN REQUEST.REQUESTOR_ID%TYPE,

                            P_REQ_STATUS_ID IN REQUEST.WFLOW_STATUS_ID%TYPE,

                            P_NSMCODEorTITLE IN VARCHAR,

                            P_NSM_LEVEL IN ORG_REQ.ORG_LEVEL_ID%TYPE, 

                            CUR_SEARCH_REQ_RESULTS OUT T_CURSOR,

                            P_OUT OUT NUMBER,

                            P_MSG OUT VARCHAR)

.net code:

 dpDataParamArr = New ArrayList

        'User's User_ID needed for Security

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, STP_Constants.P_USR_ID_NUM, "INT32", objUser.UserIdNumber, ParameterDirection.Input))

        'Optional? This was needed until an error was discovered after Rnd 2 of testing

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_ROLE_NAME", "VARCHAR", strRole, ParameterDirection.Input))

 

        'If no Request # was entered, must be set to "-1" for query to work

        If intRequestId = "" Then

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQUEST_ID", "INT32", -1, ParameterDirection.Input))

        Else

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQUEST_ID", "INT32", intRequestId, ParameterDirection.Input))

        End If

        'If no Request Title was entered, must set to "-1" for query to work

        If strReqTitle = "" Then

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQ_TITLE", "VARCHAR", -1, ParameterDirection.Input))

        Else

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQ_TITLE", "VARCHAR", strReqTitle, ParameterDirection.Input))

        End If

        'If no StartDate was entered, must set to "-1" for query to work

        If strStartDate = "" Then

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_STARTDATE", "VARCHAR", -1, ParameterDirection.Input))

        Else

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_STARTDATE", "VARCHAR", strStartDate, ParameterDirection.Input))

        End If

        'If no EndDate was entered, must set to "-1" for query to work

        If strEndDate = "" Then

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_ENDDATE", "VARCHAR", -1, ParameterDirection.Input))

        Else

            dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_ENDDATE", "VARCHAR", strEndDate, ParameterDirection.Input))

        End If

 

        'Requestor ID defaults to "-1" in dropdown if nothing is selected

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQUESTOR_ID", "INT32", intRequestorId, ParameterDirection.Input))

 

        'Request Status defaults to "-1" in dropdown if nothing is selected

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_REQ_STATUS_ID", "INT32", intRequestStatus, ParameterDirection.Input))

 

        'NEW CODE TO SEARCH BY CODE 4/6/2006 EDGAR P_NSMCODEorTITLE

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_NSMCODEorTITLE", "VARCHAR", strTitleOrCode.Trim, ParameterDirection.Input))

        'END NEW

        'JT 2.1 Add NSM Level defaults to "-1" in dropdown if nothing is selected

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, "P_NSM_LEVEL", "INT32", intNSMLevel, ParameterDirection.Input))

 

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, STP_Constants.CUR_SEARCH_REQ_RESULTS, "cursor", DBNull.Value, ParameterDirection.Output))

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, STP_Constants.P_OUT, "INT32", 0, ParameterDirection.Output))

        dpDataParamArr.Add(New DataParameter(STP_Constants.GET_REQUESTS_SRCH, STP_Constants.P_MSG, "varchar", DBNull.Value, ParameterDirection.Output))

 

        GetRequestsSrch = GetDataSet(dpDataParamArr, STP_Constants.PKG_SEARCHES, STP_Constants.GET_REQUESTS_SRCH)

Thanks,

JT

Importing data from an Excel File and using columnMapping

$
0
0

When importing data from an Excel File and using columnMapping the 00s get dropped

Example
DriverID = 1.00. It is being imported into a varchar 200 field

All fields come in correctly except 1.00 now show as 1. The 00s get dropped

sqCopy.ColumnMappings.Add("DriverID", "DriverID")

Need 1 more line of code to make the xls worksheet calculate

$
0
0

I have this code to update the value of an Excel cell in A1:

objConn.Open();
OleDbCommand objCmdUpdate = new OleDbCommand("UPDATE[Sheet1$A1:A1] SET F1 = 2000", objConn);
objCmdUpdate.ExecuteNonQuery();

It is working and update cell A1 to 2000. However, my goal is to get the calculated value of cell B1 which has formula =20*A1
Now I use this line to get cell B1

new OleDbCommand("SELECT * from [Sheet1$B1:B1]", objConn2);

It is getting a value but it is getting cell value of B1 BEFORE using new A1 to calculate B1 cell value.

What is the code above to ensure the worksheet formula to calculate ?

Thanks


Error connecting to oracle due to unexplained error.

$
0
0

I am getting the below error.

ERROR 2017-12-20 14:16:14,925 23045ms Resources Error - An unexplained error has occurred. at Devart.Data.Oracle.a3.a(cl A_0, t A_1)
at Devart.Data.Oracle.OracleInternalConnection..ctor(cl connectionOptions, OracleInternalConnection proxyConnection)
at Devart.Data.Oracle.a1.a(af A_0, Object A_1, DbConnectionBase A_2)
at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, af A_1, DbConnectionBase A_2)
at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at Devart.Common.DbConnectionBase.Open()
at Devart.Data.Oracle.OracleConnection.Open()
at Orion.DataAccess.Oracle.ORAConnection.OpenConnection() in d:\CODE\XXXXXX\Oracle\ORAConnection.cs:line 77




It was working fine and stopped working all of a sudden.
Please Help.

Please Help to insert data from DataSet in Asp.net into MySQL database using ADO.Net using Asp.net C#

$
0
0

Hi,

I have below code:

I have DS_SOURCE as DataSet Fill up from select query using regular asp.net Select statement call from MS SQL Server Database.

/////////

  try

        {

            string constrdestination = ConfigurationManager.ConnectionStrings["constrdestination"].ConnectionString;

            using (MySqlConnection conn = new MySqlConnection(constrdestination))

            {

                conn.Open();

                using (MySqlDataAdapter dAd = new MySqlDataAdapter())

                { 

                  

                  // I need help to assign dataset DS_SOURCE to MySqlDataAdapter dAd Fill property to Insert it into MySQL .

                    dAd.Fill(DS_SOURCE); 

               

                }

            }

        }

        catch(Exception Ex)

        {

            string str = Ex.ToString();

        }

        }

///////////

Now I want to insert the data in dataset obtained from MS SQL SERVER into MySQL  Database using above code:

Please Help the way by which I can Assign DataSet in Asp.net to MySqlDataAdapter Fill method and insert the same in table created in MySQL.

Thanks,

Regards,

Jayesh.

Please Help me to insert data from DataSet in Asp.net into MySql database using ADO.Net using Asp.net C#

$
0
0

Hi,

I have below code:

I have DS_SOURCE as DataSet Fill up from select query using regular asp.net Select statement ADO.Net call from MS SQL Server Database.

Now I want to insert the data in DataSet obtained in DS_SOURCE from MS SQL SERVER into MySql Database using below code:

  try

        {

            string constrdestination = ConfigurationManager.ConnectionStrings["constrdestination"].ConnectionString;         

            using (MySqlConnection conn = new MySqlConnection(constrdestination))

           {

              conn.Open();

               using (MySqlDataAdapter dAd = new MySqlDataAdapter())

                { 

                     // I need help to assign dataset DS_SOURCE to MySqlDataAdapter dAd Fill property to Insert it into MYSQL.

                     dAd.Fill(DS_SOURCE); 

               

                }

            }

        }

        catch(Exception Ex)

        {

            string str = Ex.ToString();

        }

        }

Please Help me the way by which I can Assign DataSet in Asp.net to MySqlDataAdapter Fill method and insert the same in table created in MYSQL.

Thanks,

Regards,

Jayesh.

what is the C# code to read TYPES.cursortypes in procedure

$
0
0

I have a stored procedure like this

        PROCEDURE PRC_ABCD_GETALL (resultset_out OUT TYPES.cursorType)

ASBEGIN OPEN resultset_out FOR SELECT * FROM ABCD;END PRC_ABCD_GETALL;

And my C# code is like this

using (OracleConnection conn = new OracleConnection(cnn))
{
	conn.Open();
	OracleCommand cmd = new OracleCommand();
	cmd.Connection = conn;
	cmd.CommandText = "PRC_ABCD_GETALL";
	cmd.CommandType = CommandType.StoredProcedure;
	cmd.Parameters.Add("resultset_out", OracleDbType.Cursor, ParameterDirection.Output);
	OracleDataReader rdr = cmd.ExecuteReader();
	while (rdr.Read())
	{
		result.Add(Construct(rdr));
	}
}

but I'm getting error 'OracleDbType' does not contain a definition for 'Cursor' in OracleType.Cursor. Any solution for this??</div>

Large excel

$
0
0

Hi

I have large excel which is about 30mb file. I just want to read its header and I am using EPPLus dll. When I try to load worksheet it throws System.OutOfMemory.

What will be the best way to read just column headers from excel.

Awaiting for your reply

DocumentFormat.OpenXml Currency Format Issue

$
0
0

Hi All,

Currently I am working in a vb.net web application where I need to export data to excel, I am using DocumentFormat.OpenXML package to do the same.

In that I am creating a stylesheet to format the excel, but I am facing an issue with the currency format where I need it exactly as$331.87

The below method only I am using, except the numbering format rest all works fine. Please help me to resolve it.

    Private Function GenerateStyleSheetNew() As Stylesheet
        Return New Stylesheet(New DocumentFormat.OpenXml.Spreadsheet.Fonts(New Font(New FontSize() With {.Val = 10},
                                                                                New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}},
                                                                                New FontName() With {.Val = "Arial"}),
                                                                            New Font(New Bold(),
                                                                                     New FontSize() With {.Val = 10},
                                                                                     New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}},
                                                                                     New FontName() With {.Val = "Arial"}), New Font(New Italic(),
                                                                                                                                       New FontSize() With {.Val = 10},
                                                                                                                                       New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}},
                                                                                                                                       New FontName() With {.Val = "Arial"}),
                                                                                                                                   New Font(New FontSize() With {.Val = 16},
                                                                                                                                            New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}},
                                                                                                                                            New FontName() With {.Val = "Times New Roman"})),
                                                                                                                                    New Fills(New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill() With {.PatternType = PatternValues.None}),
                                                                                                                                              New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill() With {.PatternType = PatternValues.Gray125}),
                                                                                                                                              New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill(New DocumentFormat.OpenXml.Spreadsheet.ForegroundColor() With {.Rgb = New HexBinaryValue() With {.Value = "FFFFE0"}}) With {.PatternType = PatternValues.Solid}),
                                                                                                                                          New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill(New DocumentFormat.OpenXml.Spreadsheet.ForegroundColor() With {.Rgb = New HexBinaryValue() With {.Value = "CCFFCC"}}) With {.PatternType = PatternValues.Solid})),
                                                                                                                                          New Borders(New Border(New DocumentFormat.OpenXml.Spreadsheet.LeftBorder(),
                                                                                                                                                                 New DocumentFormat.OpenXml.Spreadsheet.RightBorder(),
                                                                                                                                                                 New DocumentFormat.OpenXml.Spreadsheet.TopBorder(),
                                                                                                                                                                 New DocumentFormat.OpenXml.Spreadsheet.BottomBorder(),
                                                                                                                                                                 New DiagonalBorder()),
                                                                                                                                                             New Border(New DocumentFormat.OpenXml.Spreadsheet.LeftBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin},
                                                                                                                                                                        New DocumentFormat.OpenXml.Spreadsheet.RightBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin},
                                                                                                                                                                        New DocumentFormat.OpenXml.Spreadsheet.TopBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin},
                                                                                                                                                                        New DocumentFormat.OpenXml.Spreadsheet.BottomBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin},
                                                                                                                                                                        New DiagonalBorder())), New DocumentFormat.OpenXml.Spreadsheet.NumberingFormats(New DocumentFormat.OpenXml.Spreadsheet.NumberingFormat() With {.NumberFormatId = 1, .FormatCode = "#,##0.00"}), New CellFormats(New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 0},
                                                                                                                                                                                                                New CellFormat() With {.FontId = 1, .FillId = 0, .BorderId = 0, .ApplyFont = True},
                                                                                                                                                                                                                New CellFormat() With {.FontId = 2, .FillId = 0, .BorderId = 0, .ApplyFont = True},
                                                                                                                                                                                                                New CellFormat() With {.FontId = 3, .FillId = 2, .BorderId = 1, .ApplyFont = True},
                                                                                                                                                                                                                New CellFormat(New Alignment() With {.Horizontal = HorizontalAlignmentValues.Center, .Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 1, .FillId = 3, .BorderId = 1, .ApplyFill = True, .ApplyAlignment = True},
                                                                                                                                                                                                                New CellFormat(New Alignment() With {.Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 0, .FillId = 2, .BorderId = 1, .ApplyAlignment = True},
                                                                                                                                                                                                                 New CellFormat(New Alignment() With {.Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 0, .FillId = 0, .BorderId = 1, .ApplyAlignment = True},
                                                                                                                                                                                                                New CellFormat(New Alignment() With {.Horizontal = HorizontalAlignmentValues.Center, .Vertical = VerticalAlignmentValues.Center}) With {.FontId = 0, .FillId = 0, .BorderId = 0, .ApplyAlignment = True, .NumberFormatId = 166, .ApplyNumberFormat = True},
                                                                                                                                                                                                                New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 0, .NumberFormatId = 166, .ApplyNumberFormat = True},
                                                                                                                                                                                                                New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 1, .ApplyBorder = True}))
    End Function

literal does not match format string

$
0
0

Hi,

i am trying to get the current date using "txtdate.Text = Now.Date.ToString("yyyy-MM-dd")" in VB.net but problem is when i inserting into oracle DB throwing exception "ERROR [22007] [Microsoft][ODBC driver for Oracle][Oracle]ORA-01861: literal does not match format string". i am using below insert command. what could be the issue

"INSERT INTO SCHEDULE (PROJECT_NUM, UNITS, INSPECT_DATE, last_update_date,creation_date )  VALUES ('002342','14','2018-01-02',sysdate,sysdate)"

Thanks in advance


1000s of Inactive session in Oracle

$
0
0

There are 1000s of Inactive sessions are there in Oracle database. Some are even 1 month old.

sql_text shows a particular query in 90% of the cases. Query is working fine without any slowness.

OracleConnection is disposed properly.

Any idea what can be reason ?

Query used to find inactive sessions

SELECT s.SID, s.STATUS, s.process, s.osuser, a.sql_text, p.program FROM v$session s, v$sqlarea a, v$process p WHERE s.PREV_HASH_VALUE = a.hash_value

AND s.PREV_SQL_ADDR = a.address AND s.paddr = p.addr AND s.STATUS = 'INACTIVE'

insert the records into excel useing C#

$
0
0

Hi All

i am doing insert the records into excel .

query is working fine, but records are  not inserting into Excel

 code is       like below

try
{
	string fileLocation = Server.MapPath("~/Upload/Test_Web.xlsx");
	System.Data.OleDb.OleDbConnection MyConnection;
	System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
	strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0 xml;HDR=Yes;\"";
	MyConnection = new System.Data.OleDb.OleDbConnection(strConn);
	if (MyConnection.State.ToString() == "Closed")
	{
		MyConnection.Open();
	}
	myCommand.Connection = MyConnection;
	string sql = "INSERT INTO [Sheet1$] ([username],[password]) VALUES('siddu', '4646')";
	// string sql =""Insert into[Sheet1$] (username, password) values('siddu', '344')";
	myCommand.CommandText = sql;
	myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
	// MessageBox.Show(ex.ToString());
	throw ex;
}

please suggest me 

thanks and regards

siddu

GridView to Oracle

$
0
0

Trying to get GridView to connect to Oracle.

The connection works for a simple connection, like this

                using (OracleConnection con = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConnectionString"].ConnectionString))

                {

                    con.Open();

                    OracleCommand cmd = new OracleCommand("SELECT * FROM table", con);

                    OracleDataAdapter da = new OracleDataAdapter(cmd);

                    da.Fill(dt);

                } // end Using Oracle Connection

But when I want GridView to connect to same Oracle connection, I get "The network path was not found". The google results did not work for me. I tried changing the providerName to Oracle.DataAccess.Client and System.Data.OracleClient and Oracle.ManagedDataAccess

Here is the code for the GridView

 <asp:GridView ID="GridView" runat="server" DataSourceID="ds" DataKeyNames="ID" AllowPaging="True" AllowSorting="True"

            AutoGenerateColumns="False" GridLines="Vertical" Caption="Vendors" PageSize="30">

            <AlternatingRowStyle BackColor="WhiteSmoke" />

            <Columns>

                <asp:CommandField ShowEditButton="True" ShowDeleteButton="false" ItemStyle-Width="100px" />

                <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="true" Visible="true" />

                <asp:BoundField DataField="ADDRESS_1" HeaderText="Address 1" ItemStyle-Width="200px" />

            </Columns>

        </asp:GridView>

        <asp:SqlDataSource ID="ds" runat="server" ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"

            SelectCommand="SELECT * FROM table WHERE ID = 5"

            UpdateCommand="UPDATE table SET 

                        ADDRESS_LINE1 = @ADDRESS_LINE1

                        WHERE ID = 5">

            <UpdateParameters>

                <asp:Parameter Name="ID" Type="Int32" />

                <asp:Parameter Name="ADDRESS_1" Type="String" />

            </UpdateParameters>

        </asp:SqlDataSource>

Here is the connection string in web.config. For this example I put stars for the private data.

<add name="OracleConnectionString" connectionString="Data Source=(Description=(ADDRESS=(PROTOCOL=tcp)(HOST=*)(PORT=*))(CONNECT_DATA=(SID=*)));User ID=*;Password=*" providerName="Oracle.DataAccess.Client" />

Again, the connection string works, I use it for a basic select to put data into a datatable. Just can't get it to work for a datagrid.

odp.net issue with null dates

$
0
0

We just updated to odp.net 4 and we have a date field on a form that when we try to pass this to our oracle procedure in the backend it get's a Not a Valid Month.

Looking at the code it in the Attachparameter code below it checks for null but this doesn't seem to work. We tried to put in a check and reset the value to DBNull.Value but we still get that not a valid Month error. Any help would be appreciated. 

We tried setting p.Value = OracleString.DBnull  but that gave an oracle error.  We got it to find the null with p.value=(object)System.Dbnull.value and directly set the p.value=Dbnull.value but that still gave the Oracle month error. So were not sure how to fix this issue.(code below)

 dpDataParamArr = New ArrayList

dpDataParamArr.Add(New DataParameter(STP_Constants.SAVE_ORG_REQ, STP_Constants.P_APPROVAL_DT, "DATETIME", Now, ParameterDirection.Input, 10, Req_Contants.COL_APPROVAL_DT, DataRowVersion.Current))  <--field iwth nulll

  UpdateDatasetTable(dsRequestSchema, dsRequestSchema.Tables(RequestSchema.ELEMENTS).TableName, Nothing, arrParameters, STP_Constants.PKG_M

                                 STP_Constants.SAVE, STP_Constants.SAVE, "DELETE", idbConn, idbtrax)  <--procedure to call dll that interfaces with oracle

helper.UpdateDataset(IdbInsertCommand, IdbDeleteCommand, IdbUpdateCommand, dsSrcDataset, strTableName)

DLL code below:

public void UpdateDataset(IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand, 

DataSet dataSet, string tableName, RowUpdatingHandler rowUpdatingHandler, RowUpdatedHandler rowUpdatedHandler) 

{

int rowsAffected = 0;

 

if( tableName == null || tableName.Length == 0 ) throw new ArgumentNullException( "tableName" ); 

 

// Create an IDbDataAdapter, and dispose of it after we are done

IDbDataAdapter dataAdapter = null;

try

{

bool mustCloseUpdateConnection = false;

bool mustCloseInsertConnection = false;

bool mustCloseDeleteConnection = false;

 

dataAdapter = GetDataAdapter();

                

// Set the data adapter commands

dataAdapter.UpdateCommand = SetCommand(updateCommand, out mustCloseUpdateConnection);

dataAdapter.InsertCommand = SetCommand(insertCommand, out mustCloseInsertConnection);

dataAdapter.DeleteCommand = SetCommand(deleteCommand, out mustCloseDeleteConnection);

 

AddUpdateEventHandlers(dataAdapter, rowUpdatingHandler, rowUpdatedHandler);

if( dataAdapter is DbDataAdapter ) 

{

// Update the DataSet changes in the data source

try

{

rowsAffected = ((DbDataAdapter)dataAdapter).Update(dataSet, tableName);

catch (Exception ex) 

{

// Don't just throw ex.  It changes the call stack.  But we want the ex around for debugging, so...

Debug.WriteLine(ex);

dataAdapter = null;

if (mustCloseUpdateConnection)

{

updateCommand.Connection.Close();

}

if (mustCloseInsertConnection)

{

insertCommand.Connection.Close();

}

if (mustCloseDeleteConnection)

{

deleteCommand.Connection.Close();

}

ExceptionManager.Publish(ex);

throw ex;

}

}

else

{

dataAdapter.TableMappings.Add(tableName, "Table"); 

// Update the DataSet changes in the data source

rowsAffected = dataAdapter.Update (dataSet); 

}

 

// Commit all the changes made to the DataSet

dataSet.Tables[tableName].AcceptChanges();

 

if (mustCloseUpdateConnection)

{

updateCommand.Connection.Close();

}

if (mustCloseInsertConnection)

{

insertCommand.Connection.Close();

}

if (mustCloseDeleteConnection)

{

deleteCommand.Connection.Close();

}

}catch (Exception e)

{

Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(e);

throw e; 

}

finally

{

if ( insertCommand != null )

{

insertCommand.Dispose();

//dataAdapter.InsertCommand.Dispose();

}

 

if ( updateCommand != null )

{

updateCommand.Dispose();

//dataAdapter.UpdateCommand.Dispose();

}

 

if ( deleteCommand != null )

{

deleteCommand.Dispose();

//dataAdapter.DeleteCommand.Dispose();

}

IDisposable id = dataAdapter as IDisposable;

if( id != null ) id.Dispose();

}

}

protected virtual IDbCommand SetCommand(IDbCommand command, out bool mustCloseConnection )

{

mustCloseConnection = false;

if (command != null)

{

IDataParameter[] commandParameters = new IDataParameter[ command.Parameters.Count ];

command.Parameters.CopyTo( commandParameters, 0 );

command.Parameters.Clear();

this.PrepareCommand( command, command.Connection, null, command.CommandType, command.CommandText, commandParameters, out mustCloseConnection );

CleanParameterSyntax(command);

}

return command;

}

 

protected virtual void PrepareCommand(IDbCommand command, IDbConnection connection, IDbTransaction transaction, CommandType commandType, string commandText, IDataParameter[] commandParameters, out bool mustCloseConnection )

{

if( command == null ) throw new ArgumentNullException( "command" );

if( commandText == null || commandText.Length == 0 ) throw new ArgumentNullException( "commandText" );

 

// If the provided connection is not open, we will open it

if (connection.State != ConnectionState.Open)

{

mustCloseConnection = true;

connection.Open();

}

else

{

mustCloseConnection = false;

}

 

// Associate the connection with the command

command.Connection = connection;

 

// Set the command text (stored procedure name or SQL statement)

command.CommandText = commandText;

 

// If we were provided a transaction, assign it

if (transaction != null)

{

if( transaction.Connection == null ) throw new ArgumentException( "The transaction was rolled back or commited, please provide an open transaction.", "transaction" );

command.Transaction = transaction;

}

 

// Set the command type

command.CommandType = commandType;

 

// Attach the command parameters if they are provided

if (commandParameters != null)

{

AttachParameters(command, commandParameters);

}

return;

}    

protected virtual void AttachParameters(IDbCommand command, IDataParameter[] commandParameters)

{

if( command == null ) throw new ArgumentNullException( "command" );

if( commandParameters != null )

{

foreach (IDataParameter p in commandParameters)

{

if( p != null )

{

// Check for derived output value with no value assigned

if ( ( p.Direction == ParameterDirection.InputOutput || 

p.Direction == ParameterDirection.Input ) && 

(p.Value == null))  <--doesn't find

{

p.Value = DBNull.Value;

}

if (p.DbType == DbType.Binary) 

{

// special handling for BLOBs

command.Parameters.Add(GetBlobParameter(command.Connection, p));

}

else if (p.DbType == DbType.Object)//special handle for large strings

{

command.Parameters.Add(GetClobParameter(command.Connection, p));

}

else

{

command.Parameters.Add(p);

}

}

}

}

}

 

How to Identify Excel Values based on Column Headers

$
0
0

Hi,

I have one excel with one sheet, which contains 3 columns as Customers,Products and Orders. I just need to extract values based on Header/Column Names and put
in each collection(in this case 3 collections). Thanks in advance.

Viewing all 1350 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>