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

Zip and download files from MySql database

$
0
0

What will be the best approach to zip files from mysql database in asp.net C#?


reading from excel Best approach in .net

$
0
0

I know approaches like oledb, Excel object model.

Wanted to know whats the best approach

Data sequentially operation - Rownum

$
0
0
<div class="jive-message-body">Dear All,

I have a table containing some records (Customer, DataOfPurchasments) where a customer might be purchasing in many different days. If I am willing to measure the inactivity period for this customer, what I have to do?

I was thinking to sort the customers ASC into a new table as to sort the rownum for each, the query is as below:

create table t as (Select customer,dataofPurch From sales) order by 1,2
then what I get is a sorted data regarding rownum as below:

Rownum, Customer, Dt
1, 1234, 01-Feb-2013
2, 1234, 05-Feb-2013
3, 1234, 06-feb-2013
4, 5678, 06-Feb-2013
5, 5678, 08-Feb-2013

The question, what I have to do if I want the output to be as below:

Customer, Date1,Date2,Inactivity
1234, 01-Feb-2013,05-Feb-2013,4
1234, 05-Feb-2013,06-Feb-2013,1
5678, 06-Feb-2013,08-Feb-2013,2

I was thinking in a query such as

Select Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt
From t, (Select customer, Dt From T where rownum <rownum+1)X
where t.Customer = X.customer
group by Customer,Dt Date 1,X.Dt Date2 ,Dt-X.Dt

but that wasn't helpful. So, How can I solve my problem?

Regards;</div>

Calling an Oracle Stored Procedure with ODP

$
0
0

Hello everybody !!!

I have this oracle stored Procedure :

PROCEDURE sp_cree_planning (
 pi_id_trait   IN T_TRAIT.ID_TRAIT%TYPE,
 pi_f_actif   IN T_PLANNING.F_ACTIF%TYPE,
 pi_id_si    IN T_PLANNING.ID_SI%TYPE,
 pi_lst_loc   IN TABLE_NUMBER,
 pi_lst_par_nom IN table_varchar2_50,
 pi_lst_par_val IN table_varchar2_200,
 pi_d_modif   IN DATE,
 pi_id_user   IN T_USERS.ID_USER%TYPE,
  po_c_erreur   OUT NUMBER,
 po_des_erreur  OUT VARCHAR2 )
IS

l_nom_param   T_PLANNING_PARAM.NOM_PARAM%TYPE;
l_valeur_param T_PLANNING_PARAM.VALEUR_PARAM%TYPE;
l_id_planning  T_PLANNING.ID_PLANNING%TYPE;
l_tab_par    table_par;

l_err_fonc     EXCEPTION;
po_c_erreur_trait  NUMBER;
po_des_erreur_trait VARCHAR2(2000);
BEGIN
po_c_erreur := Pck_Erreur.CST_OK;

 sp_tab_param(pi_lst_par_nom,pi_lst_par_val ,l_tab_par,po_c_erreur_trait,po_des_erreur_trait);
 IF po_c_erreur_trait <> Pck_Erreur.CST_OK THEN
  po_c_erreur := po_c_erreur_trait;
  po_des_erreur := po_des_erreur_trait;
  RAISE l_err_fonc;
 END IF;



IF pi_lst_loc.COUNT <> 0 THEN
 FOR i IN pi_lst_loc.FIRST..pi_lst_loc.LAST  LOOP
  -- création du planning : lien job-lieu
  SELECT SEQ_PLANNING.NEXTVAL INTO l_id_planning  FROM dual;
  INSERT INTO T_PLANNING(ID_PLANNING,ID_TRAIT,ID_LOC,ID_SI,F_ACTIF,ID_USER,D_MODIF)
  VALUES (l_id_planning,pi_id_trait,pi_lst_loc(i),pi_id_si,pi_f_actif,pi_id_user,pi_d_modif);

  IF l_tab_par.COUNT <>0 THEN
    FOR j IN l_tab_par.FIRST..l_tab_par.LAST LOOP
     IF l_tab_par(j).par_nom IS NOT NULL THEN
       INSERT INTO T_PLANNING_PARAM(ID_PLANNING,NOM_PARAM,VALEUR_PARAM,ID_USER, D_MODIF) VALUES
       (l_id_planning,l_tab_par(j).par_nom,l_tab_par(j).par_val,pi_id_user,pi_d_modif);
     END IF;
    END LOOP;
  END IF;
 END LOOP;
END IF;

Somebody may tell me how to call this procedure using C#?

The dificulty is here :

 pi_lst_loc   IN TABLE_NUMBER,
 pi_lst_par_nom IN table_varchar2_50,
 pi_lst_par_val IN table_varchar2_200,

I don't know how to use it here for example :

            Parameter piIdTrait = new Parameter { Name = ParamIdRequest, Type = OracleDbType.Int64, Direction = ParameterDirection.Input };
            piIdTrait.Value = (Int64?)Int64.Parse(idRequest);
            proc.Parameters.Add(piIdTrait );


Thanx very much


Reading phpBB posts

$
0
0

Hi all,

My question put simply: I have a phpBB board on my server. I want to read the latest news announcement from it and display it on my web site's main page. Everything's fine and dandy; topic title, timestamps, reply counts etc. all work, except for the actual post contents.

Let's say the post text is something along the lines of "Lorem ipsum dolor sit amet, consectetur bla bla". What my code actually returns is not that but some garbled version like "57656C6C2C2049206775657373207468697320".

Code (see below) in short: Grab the last topic's (sorting by timestamp, descending, limit 1 = latest topic) metadata from the phpbb_topics table, get the post ID of the topic's first post, and then look that post's text up in the phpbb_posts table.

`phpbb_posts`.`post_text` is a mediumtext utf8_bin (this is the column where the reading apparently goes wrong). The only other text field I'm reading from is `phpbb_topics`.`topic_title`, which is a varchar(255) utf8_general_ci. I'm lead to believe that it has something to do with the post_text column having a binary collation, but I don't know how to fix the reading problem.

Using MySQL 5.

VB.NET code:

Public Function GetLastNewsPost() As System.Collections.Generic.List(Of Object)
            Dim Result As New System.Collections.Generic.List(Of Object)
            Dim NewsTitle As String = "", NewsID As Integer, NewsTime As Long, NewsReplies As Integer
            Dim NewsText As String = "", NewsFirstPostID As Integer

            Try
                ' Generate SQL database connection and open.
                Dim SQLConn As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=xxxxx;Uid=xxxxx;Pwd=xxxxx;")
                SQLConn.Open()

                Dim SQLCommand As New OdbcCommand("SET NAMES 'utf8';", SQLConn)
                SQLCommand.ExecuteNonQuery()
                SQLCommand.Dispose()

                ' Create a reader
                Dim Reader As OdbcDataReader = Nothing

                ' Create SQL query.
                SQLCommand = New OdbcCommand("SELECT `topic_id`, `topic_title`, `topic_time`, `topic_replies`, `topic_first_post_id` FROM `phpbb_topics` WHERE `forum_id`=2 ORDER BY `topic_time` DESC LIMIT 1", SQLConn)
                Try
                    ' Generate a reader
                    Reader = SQLCommand.ExecuteReader

                    If Reader.HasRows AndAlso Reader.Read Then
                        ' read only the latest post
                        NewsID = Reader.GetInt32(0)
                        NewsTitle = Reader.GetString(1)
                        NewsTime = Reader.GetInt64(2)
                        NewsReplies = Reader.GetInt32(3)
                        NewsFirstPostID = Reader.GetInt32(4)
                        SQLCommand.Dispose()
                        Reader.Close()

                        ' Create SQL query.
                        SQLCommand = New OdbcCommand("SELECT `post_text` FROM `phpbb_posts` WHERE `post_id`=" & NewsFirstPostID & " LIMIT 1", SQLConn)
                        Reader = SQLCommand.ExecuteReader

                        If Reader.HasRows AndAlso Reader.Read Then
                            NewsText = Reader.GetString(0)
                        End If
                        SQLCommand.Dispose()
                    End If
                Finally
                    SQLConn.Close()
                    If Reader IsNot Nothing Then Reader.Close()
                End Try

            Catch ex As Exception
                ' DB error
                NewsTitle = "<Database error occurred: " & ex.GetType.FullName & ">"
            End Try

            Result.Add(NewsID)
            Result.Add(HttpUtility.HtmlEncode(NewsTitle))
            Result.Add(NewsTime)
            Result.Add(NewsReplies)
            Result.Add(HttpUtility.HtmlEncode(NewsText))
            Return Result
        End Function

If anyone could give me some ideas, that would be awesome.

Thanks!

textbox/checkbox/dropdownlist values, insert into Oracle db

$
0
0

I have created my Oracle DB, and established the connection within my visual studio. (call it TEST_DB)...

Now say I have 1 textbox (Name), 1 checkbox (gender), and 1 dropdownlist (state),

What is the c# code to take the entered values after SubmitButton was clicked, and insert them into my oracle DB Columns?...

thanks in advance

Sql Query

$
0
0

hello i have the following error :ORA-01036: illegal variable name/number

in below query

      cmdMain.CommandText = " SELECT :CL_CLASS     " & _
                                    " FROM   TABLE1                    " & _

                        " WHERE  COUNTRY = 'Brazil'          " & _
                          " AND    POLICYSEQ = 1            " & _
                                               " AND    ROWNUM = 1                          "
            cmdMain.Parameters.Add(":CL_CLASS", OracleType.NVarChar, 1).Value = CL_CLASS

please help i think the error when using the symbol :

how to take mys sql backup between two dates using asp.net c#

$
0
0

Hi community,

i am implemting backup functionality in web application complete database backup is sucessfully done using c# but i

I am facing problem as user defined backup date  for e.g if want to take backup from 5-june-2013 to 8-june 2013

how can i am implement this backup functionality..

Thanks...


ODBC Parameter Error

$
0
0

Hi all,

I am getting this error: "The OdbcParameter is already contained by another OdbcParameterCollection." in my DAL class file.

I have made website which uses MySQL database and for that I have used ODBC. When I call below mentioned method 'GetValueBySQL' which calls 'PrepareCommand' in which I am getting error at the last line.

I tried for solution on google but can't find it. Please help.

public string GetValueBySQL(string strSQL, params OdbcParameter[] ocmdParms)
        {
            OdbcCommand ocmd = new OdbcCommand();
            PrepareCommand(ocmd, om_conn, null, strSQL, ocmdParms);

            string Value = string.Empty;
            object o = ocmd.ExecuteScalar();
            if (!(o == null || o == System.DBNull.Value))
            {
                Value = o.ToString();
            }

            CloseConnect();
            return Value;
        }


private void PrepareCommand(OdbcCommand ocmd, OdbcConnection conn, OdbcTransaction trans, string ocmdText, OdbcParameter[] ocmdParms)
        {
            if (conn.State != ConnectionState.Open)
                conn.Open();
            ocmd.Connection = conn;
            ocmd.CommandText = ocmdText;
            if (trans != null)
                ocmd.Transaction = trans;
            ocmd.CommandType = CommandType.Text;
            if (ocmdParms != null)
            {
                ocmd.Parameters.Clear();

                foreach (OdbcParameter parameter in ocmdParms)
                {
                    if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
                        (parameter.Value == null))
                    {
                        parameter.Value = DBNull.Value;
                    }
                    ocmd.Parameters.Add(parameter);
                }
            }
        }


Advance thanks,
Suraj Joshi.

Splitting comma separated string inside function

$
0
0

How to split comma separated string into an array which is passed to an oracle function as a parameter and then iterating

through every element of array..... 

ORA-01017: invalid username/password; logon denied

$
0
0

Hi,

I'm trying to obtain data from an Oracle 10g DB, but I've been found a trouble series and now i'm stucked. This is all i've done:

1. Install Oracle 10g client (http://www.oracle.com/technetwork/database/windows/install10104-087102.html)

Got:

ORA-12154: TNS:could not resolve the connect identifier specified

It was 'cause i've missing to configure tnsnames, so...

2. Configure TNSNAMES.ORA and sqlnet.ora (both in the same path C:\oracle\product\10.1.0\Client_1\network\ADMIN )

TNSNAMES.ORA

etpschp3=(
	DESCRIPTION =(
		ADDRESS=(PROTOCOL=tcp)
			(HOST=ip_address)
			(PORT=1528)
		)
	(CONNECT_DATA=
		(SERVICE_NAME =etpschp3)
	)
)

sqlnet.ora

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

3. Add environment variables ORACLE_HOME and TNS_ADMIN

oracle home

tns admin

4. Check "Allow inprocess" on OraOLEDB.Oracle DataProvider 

Now the error was different:

ORA-12545: Connect failed because target host or object does not exist
<div>5. I've got to add server in HOST file</div><div></div><div>Got new error:</div><div>
ora-01017 invalid username/password logon denied
<div>Actually there's other server with a SQL Server with a linked server with the same user/password that i'm using. Also i've been configured an UDL in my machine, and connection test was successful.</div></div><div></div><div>I don't get where's my mistake. I get this error in a linked server (in my machine) and in an ASP application using System.Data.OleDb and System.Data.OracleClient.</div>

string str = "Data Source=etpschp3;Persist Security Info=True;"
                    + "User ID=usr;Password=passwd;";

                DataSet ds = new DataSet();
                OracleConnection oraCnn = new OracleConnection(str);   //("Data Source=etpschp3; User Id=OS_APP; Password=OSS55USER;");
                OracleCommand cmd = new OracleCommand("select count(*) from FROM tboss.osst_cust", oraCnn);

                OracleDataAdapter da = new OracleDataAdapter(cmd);

OleDbConnection cn = new OleDbConnection("Provider=MSDAORA;" +
                      "Data Source = etpschp3 ;" +
                      "User ID= usr;" +
                      "Password = passwd;");

                OleDbCommand cmd = new OleDbCommand("select count(*) from FROM tboss.osst_cust", cn);
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);


                da.Fill(ds);
                


Somebody help!

Thanks in advance

Working with EF for Oracle database. “Schema specified is not valid”

$
0
0

The field in Oracle database is of NUMBER(5), and when I generate EF models from the oracle database, it converts the field into "Int16". There are some of the rows for that field having values such as "50000", etc, so Int16 is throwing error for obvious reasons. Now I tried changing it to Int32, and also Decimal in EF models, but it is now giving an error saying -

Member Mapping specified is not valid. The type 'Edm.Decimal[Nullable=True,DefaultValue=,Precision=,Scale=]' of member 'Field1' in type 'MyApp_Models.MyTable' is not compatible with 'OracleEFProvider.number

Any idea what is wrong here, and what is possible solution of this?

Any help on this much appreciated.

[MySQL] Exclude all the rows with the same ID that are within an hour

$
0
0

Hi guys, I need suggestion for show from my mysql table only the first row grouped by unique tblID and to exclude all the rows with the same tblID that are within an hour compared to the previous row.

E.g.:

+----------+---------------------+
| tblID    | theDate             |+----------+---------------------+
| 77002221 | 2013-06-12 11:17:29 |
| 56009055 | 2013-06-12 11:17:29 |
| 77002221 | 2013-06-12 11:47:29 |
| 77002221 | 2013-06-12 12:17:29 |
| 77002221 | 2013-06-12 12:47:29 |+----------+---------------------+

In this example I need show only this output:

+----------+---------------------+ 
| tblID    | theDate             | 
+----------+---------------------+ 
| 77002221 | 2013-06-12 11:17:29 | 
| 56009055 | 2013-06-12 11:17:29 | 
| 77002221 | 2013-06-12 12:47:29 | 
+----------+---------------------+ 

Because this rows compared to the first row with tblID 77002221 fall within one hour:

+----------+---------------------+ 
| tblID    | theDate             | 
+----------+---------------------+ 
| 77002221 | 2013-06-12 11:47:29 | 
| 77002221 | 2013-06-12 12:17:29 | 
+----------+---------------------+ 

Can you help me?

Thank you in advance.

DROP TABLE IF EXISTS `timediff`;
CREATE TABLE `timediff` (
  `tblID` int(10) DEFAULT NULL,
  `theDate` datetime DEFAULT NULL,
  `id` int(10) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records of timediff
-- ----------------------------
INSERT INTO `timediff` VALUES ('77002221', '2013-06-12 11:17:29', '1');
INSERT INTO `timediff` VALUES ('56009055', '2013-06-12 11:17:29', '2');
INSERT INTO `timediff` VALUES ('77002221', '2013-06-12 11:47:29', '3');
INSERT INTO `timediff` VALUES ('77002221', '2013-06-12 12:17:29', '4');
INSERT INTO `timediff` VALUES ('77002221', '2013-06-12 12:47:29', '5');

CreateUserWizard Control using Oracle

$
0
0

I am trying to extend the registration page (using this tutorial ) to add more fields to a separate database. 

I am using Oracle and but the code below uses MS SQL hence sqlDataSource... 

Can anyone help me traslate this into oracle? I really don't understand what's going on here. Looks like its inserting a 'UserId' but in which table?? 

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    TextBox UserNameTextBox =  (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");
    SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

    MembershipUser User = Membership.GetUser(UserNameTextBox.Text);
    object UserGUID = User.ProviderUserKey;

    DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
    DataSource.Insert();
}

The way I usually insert items into Oracle using ASP.net is this way (below) but the above code don't look anything like it.

DataTable dt = new DataTable();
        using (OracleConnection con = new OracleConnection(connectionString))
        {
            OracleCommand cmd = new OracleCommand();
            string sql = "INSERT INTO UserAddresses (UserId) VALUES (:UserId)";
            cmd.Parameters.AddWithValue("userid", uselbl.text);

            cmd.Connection = con;
            cmd.CommandText = sql;
            con.Open();

            try
            {
                cmd.ExecuteNonQuery();
                ErrorMessage.Text = "Successful!";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }




mysql connector problem

$
0
0

Hi;
I using asp.net 4.0 and mysql for web service.Firstly I download latest version of mysql connector 6.6.5 .After that I install MySQL Library 6.2.5.Because when I used 6.6.5 connector,I encountered trust level problem I succesfully create both of them.When I add reference for 6.2.5 mysql.data.dll to project on host.

Could not load file or assembly 'MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

error in host.I used C:\Program Files (x86)\MySQL\MySQL Connector Net 6.2.5\Assemblies\mysql.data.dll for import project.I checked the GAC folder only exist this folder name v4.0_6.6.5.0__c5687fc88969c44d 
no file name 6.2.5:
Which dll add reference to Vs2012 for succesfully work? 
My web service doesn't work correctly on host.How can I solve this problem ?

Thanks in advance 


ORA-01858: a non-numeric character was found where a numeric was expected

$
0
0

 
I have a function that takes in a collection of SearchCriteria Objects: columnName or Key, operator (<, <=, like, etc), and value.

The function builds up a Command Object. I made the value a command parameter and now my Unit Tests will not work for Dates. But all of my Unit Tests work against all other datatypes like varchar.

In the debugger, one of my date unit tests that fail end up with the cmd looking like this:

SELECT * FROM (SELECT DocumentId
               FROM idx1_AuthLetters a
               INNER JOIN Documents b ON a.DocumentId = b.Id
               WHERE Status in ('L','S','V')  AND  letter_date <= :1
               ORDER BY DOCUMENTID )
WHERE RowNum <= 14 I did have the parameter named like :letter_date. But I might have :letter_date >= ### && :letter_date <= ### where I am looking between two dates. I cannot have the same parameter name twice so I use an i++ counter as parameter name while I am looping through all of my SearchCriteria Objects. Odd to see a parameter named like this I know but it is working for the most part.

If I take this and put in my Query Window, and inspect the param value and plug that in:

SELECT * FROM (SELECT DocumentId
               FROM idx1_AuthLetters a
               INNER JOIN Documents b ON a.DocumentId = b.Id
               WHERE Status in ('L','S','V')  AND 
                     letter_date <= TO_DATE('2013-1-21', 'yyyy-mm-dd')
               ORDER BY DOCUMENTID )
WHERE RowNum <= 14 it works fine. But it will not work from the C# code from my Unit Test. Again this works for all other data types. And it use to work before I parameterized the value in the select statement.

Exact error is:

{"ORA-01858: a non-numeric character was found where a numeric was expected"}
 

AES_Decrypt not working in VS 2010

$
0
0

Hi

I have developed a solution in VS2010 where data is stored in MySQL database on a Win 2008 server. I have imported some data from Excel sheet to one of the table using SQL query and some fields are encrypted using the same encryption key used in asp.net application (Eg. Aes_Ecrypt(fieldname,'abcdefg')). But when I open the web page, encrypted fields are blank and vice versa. i.e., encrypted field added from web page cannot be viewed with a mysql query.

Could anyone help on this, please

Thanks

JP

 

Read Excel Comments

$
0
0

Hi

I am reading in an Excel sheet (.xls) into a datatable which works fine.  However some cells in the Excel sheet also contain comments (red trianle in top right of cell), is there any way I can access these comments via asp.net

many thanks in adcance

Oracle Data Access not working after Visual Studio 2012 Reinstall

$
0
0

Hi all,

Today I had to reinstall my Visual Studio 2012 unfortunately, and after doing so my ODAC has sort of been 'broken' in the midst of this install. It is a very simple oracle access for my project, but for some reason the project is saying ODAC is not installed when I try to visit the page that utilizes the ODAC. When I look in my solution, reference for ODAC is present ("Oracle.DataAccess"), my web.config file contains all of the ConnectionString information that it did prior to the reinstallation. This is why I am confused. It appears that the necessary stuff for ODAC "is there", but according to VS2012... it's not. What would you suggest to me for my issue. Error below that I am receiving when I try to visit the page utilizing the ODAC.

Unable to find the requested .Net Framework Data Provider.  It may not be installed.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.

Thank you very much,

Nick

GET AND EXECUTE THE STORE PROCEDURE DYNAMICALLY VIA C#.NET

$
0
0

Hi...

I need to get already created stored procedure from text box,after getting the store procedure  i have to execute the store procedure via c#.net in mysql. I dont know how to do this..pls help me ..

DELIMITER $$

USE `ems_hyd_question_paper_delivery`$$

DROP PROCEDURE IF EXISTS `folio_insertion`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `folio_insertion`(examId INT(11), ruleId  VARCHAR(50), coursetypeId VARCHAR(50),academicYear VARCHAR(50), rsastatusflag INT(11))
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
    ROLLBACK;
END;
SET autocommit=0;
START TRANSACTION;
 
IF(rsastatusflag = 1) THEN
SET @ExeQuery= CONCAT("
INSERT INTO result_student_folio( folio_no,student_id, exam_id,course_type,term_name,updated_on)
SELECT NULL, rsa.student_id, rsa.exam_id, cm.course_type,
(CASE WHEN sm.student_status<>7 THEN MAX(ctm.term_name)
ELSE (SELECT MAX(ctm1.term_name) FROM course_term_master ctm1 WHERE ctm1.term_id=sm.current_term_id) END ) AS term_name, CURRENT_TIMESTAMP
FROM students_master sm,
  result_student_application rsa,
   course_master cm,
  academic_year ay,
  course_term_master ctm
WHERE sm.id = rsa.student_id
AND sm.join_academic_id=ay.academic_id
AND ay.academic_id IN(",academicYear,")
    AND sm.rule_id IN(",ruleId,")
    AND cm.course_id=sm.course_id
    AND ctm.term_id = rsa.student_term_id
    AND cm.course_type IN(",coursetypeId,")
    AND rsa.exam_id = ",examId,"
    AND sm.student_status IN (1,2,4,7,8)
    AND rsa.is_ht_provided = 1
     
    AND (sm.id) NOT IN(SELECT rsf.student_id FROM result_student_folio rsf WHERE rsf.exam_id=",examId,")
GROUP BY rsa.student_id;");
ELSE
SET @ExeQuery= CONCAT("
INSERT INTO result_student_folio( folio_no,student_id, exam_id,course_type,term_name,updated_on)
SELECT NULL, rsa.student_id, rsa.exam_id, cm.course_type,
(CASE WHEN sm.student_status<>7 THEN MAX(ctm.term_name)
ELSE (SELECT MAX(ctm1.term_name) FROM course_term_master ctm1 WHERE ctm1.term_id=sm.current_term_id) END ) AS term_name, CURRENT_TIMESTAMP
FROM students_master sm,
  result_student_application_all rsa,
  course_master cm,
 academic_year ay,
 course_term_master ctm
WHERE sm.id = rsa.student_id
AND sm.join_academic_id=ay.academic_id
AND ay.academic_id IN(",academicYear,")
    AND sm.rule_id IN(",ruleId,")
    AND cm.course_id=sm.course_id
    AND ctm.term_id = rsa.student_term_id
    AND cm.course_type IN(",coursetypeId,")
       AND rsa.exam_id = ",examId,"
    AND sm.student_status IN (1,2,4,7,8)
    AND rsa.is_ht_provided = 1
    
     AND (sm.id) NOT IN(SELECT rsf.student_id FROM result_student_folio rsf WHERE rsf.exam_id=",examId,")
GROUP BY rsa.student_id");
 
END IF;
  PREPARE PREPARESTMTQURY FROM @ExeQuery;
EXECUTE PREPARESTMTQURY;
 SELECT fn_folio_updation(examId);
COMMIT;
 
    END$$

DELIMITER ;

the above one is sample storedprocedure. and my c# code is

 public static int executeSp(string exe)
        {
            try
            {    
               return PortalMySqlHelper.ExecuteProcedure(Utility.ConnectionString(),exe);            
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        public static int ExecuteProcedure(string connectionString, string commandText)
        {
            using (MySqlConnection cn = new MySqlConnection(connectionString))
            {
                cn.Open();
                MySqlCommand cmd = new MySqlCommand(commandText, cn);              
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.ExecuteNonQuery();           
                return 1;
 
            }

        }
When i get and execute the store procedure it gives the following error

"Fatal error during command execution"

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>