亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? adohandler.cs

?? Adding and making operations LOB data in a database with C#
?? CS
字號:
/**************************************************************************
@author  Chandar
@version 1.0
Development Environment        :  Visual C#.Net Beta2
Name of the File               :  ADOHandler.cs
Creation/Modification History  :
                                  02-AUG-2001     Created

File Overview
This file defines the class and its functions to communicate and work with
the database. 
**************************************************************************/

//include standard namespaces
using System;
using System.Collections;

namespace LOBSample
{
	/// <summary>
	/// Summary description for OraLOB class to handle database functions.
	/// </summary>
	public class OraLOB
	{
			ADODB.Connection m_conn;   //Declare ADODB connection object
		
		//constructor
		public OraLOB()
		{}

        /***************************************************************
		 * This function is used to open a connection to the database  
		 * ***********************************************************/
		public bool ConnectDatabase()
		{
			try
			{  				
				//specify the connection attributes in connection string
				string strConnectionString = "Provider=OraOLEDB.Oracle;"  +
										     "Data Source=" + ConnectionParams.Datasource +    
					                         "; User Id=" + ConnectionParams.Username +
					                         ";Password=" +ConnectionParams.Password ;
				//Instantiate connection object
				m_conn=new ADODB.Connection();
				m_conn.ConnectionString = strConnectionString;

				//Open the connection
				m_conn.Open("","","",0);
			
				
			}
			//Catch the exception occured during connecting	
			catch(Exception e)
			{
				//Display error message
				System.Windows.Forms.MessageBox.Show(e.Message);
				return false;
			}
			return true;   //connected successfully
		}
		
		/*********************************************
		 * This function closes connection to database
		 * ******************************************/
		public void CloseDatabase()
		{
			m_conn.Close();
		}

		/*************************************************************
		 * This function gets the product names and id's from database
		 * and displays them in the list box on form
		 * **********************************************************/
		public bool getProductNames(StartForm p_imgDlg)
		{
			try
			{
				//Create a ADODB recordset object
				ADODB._Recordset rs=new ADODB.Recordset();
				
				//Specify the SQL statement to execute
				string sql="select product_id,product_name from product_information";
			    
				//Open the recordset specfiying the connection, cursor and locktype 
				//for retrieving data
				rs.Open(sql,m_conn,ADODB.CursorTypeEnum.adOpenStatic,ADODB.LockTypeEnum.adLockOptimistic,0);
				
				//Loop till recordset contains data
				while(!rs.EOF)
				{ 
					//Retrieve the product id and name .Use appropriate casting
					string pid=((decimal)rs.get_Collect("product_id")).ToString();
					string pname=(string)rs.get_Collect("product_name");

					//Create a ComboData class object using name and id
					ComboData itemdata= new ComboData(pname,pid);
					
					//Add this object to list box. ToString funcion of ComboData
					//is called which returns the product name for display
					p_imgDlg.comboProduct.Items.Add(itemdata);
					
					//Move to next row
					rs.MoveNext();
				}
			}
			catch(Exception e)
			{
				//Display error message
				System.Windows.Forms.MessageBox.Show(e.Message);
				return false;
			}
			return true;
		}

        /**********************************************************************************
		 * This function gets the image for selected product and writes it to a 
		 * temporary file in following steps:
		 * 1. Open a recordset object to get the image length of the selected product
		 * 2. Create a command object and to call the stored procedure.
		 * 3. Set the 'SPPrmsLOB' property to true 
		 * 4. Create the parameters for product id and image and append to command object
		 * 5. Execute the command
		 * 6. Create a temporary file and write the image bytes to it.
		 * *********************************************************************************/
		public bool GetProductImage(string p_productid)
		{
			//Delete the temporary file in the application directory
			System.IO.File.Delete(System.Windows.Forms.Application.StartupPath + "/tempimage.gif");
			
			int imgsize;  //variable to hold image size

			try
			{
				//Create a recordset object
				ADODB.Recordset rs=new ADODB.Recordset();
				
				//Specify SQL statement to get image length for selected product
				string strSQL="select dbms_lob.getlength(product_image)imglength from " +
					           " product_information where product_id="+p_productid;
                
				//Open recordset object
				rs.Open(strSQL,m_conn,ADODB.CursorTypeEnum.adOpenStatic,ADODB.LockTypeEnum.adLockOptimistic,0);
				
				//Retrieve image length from recordset
				string temp =((decimal)rs.get_Collect("imglength")).ToString();
				rs.Close(); //close recordset

				//Convert string to int
				imgsize=Int32.Parse(temp);
		
				if(imgsize!=0)  //if image exists
				{
					//Call stored procedure using ODBC escape sequence
					string strProc="{Call getProductImage(?,?)}";

					//Create command object
					ADODB.Command cmd =new ADODB.Command();

					//Set its active connection to open connection
					cmd.ActiveConnection=m_conn;

					//Set the command type to text
					cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;

                   //Set command text to SQL statement 
					cmd.CommandText=strProc;
              
					//Set the 'SPPrmsLOB' property to true. This is required to tell the
					//provider that a LOB parameter is being passed

					ADODB.Properties properties;
					
					//Get the command properties into ADO properties object
					properties=cmd.Properties;

					//Obtain an enumerator of the properties
					System.Collections.IEnumerator ienum=properties.GetEnumerator();
					
					ADODB.Property singleprop;
					while(ienum.MoveNext())  //loop thorugh the enumerator
					{
						//Get the current property in to Property object
						singleprop=(ADODB.Property)ienum.Current;

						//Get the name of current property
						string propname= singleprop.Name;

						//if its is 'SPPrmsLOB' set it to true
						if(propname.Equals("SPPrmsLOB"))
							singleprop.Value=true;
					}
                    
					//Convert productid from string to integer
					int proid=Int32.Parse(p_productid);

					//Create Command parameter for product id (IN parameter)
             		ADODB._Parameter productid=cmd.CreateParameter("pid",ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamInput,20,proid);
					
					//Append the parameter to command object
					cmd.Parameters.Append(productid);
				
					//Create command parameter for product image (OUT parameter)
					ADODB._Parameter pimage = cmd.CreateParameter("pimage",ADODB.DataTypeEnum.adLongVarBinary,ADODB.ParameterDirectionEnum.adParamOutput,(int)imgsize +1,"");				
					
					//Append the parameter to command object
					cmd.Parameters.Append(pimage);

					object recs=0;
					object tparams=proid;
		            
					//Execute the command
					cmd.Execute(out recs,ref tparams,1);	
			        
					//Set SPPrmsLOB property to false
					//Reset the enumerator containing command properties to initial position
					ienum.Reset();
					while(ienum.MoveNext())  //loop thorugh the enumerator
					{
						//Get the current property into Property object
						singleprop=(ADODB.Property)ienum.Current;

						//Get the name of current property
						string propname= singleprop.Name;

						//if its is 'SPPrmsLOB' set it to true
						if(propname.Equals("SPPrmsLOB"))
							singleprop.Value=false;
					}
					//Create a file object
					System.IO.FileStream file;
				    
					//Create a temporary file for writing the image bytes
					file=new System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "/tempimage.gif",System.IO.FileMode.Create);
				    
					//Obtain an enumerator for command parameters
					IEnumerator ienumparam=cmd.Parameters.GetEnumerator();
		
					while(ienumparam.MoveNext()) //iterate through the enumerator
					{
					    //Get the current parameter into Parameter object
						ADODB._Parameter image=(ADODB._Parameter)ienumparam.Current;

                        if(image.Name.Equals("pimage")) //if parameter is for image
						{
							//Obtain the value returned by stored procedure into byte array
							int x =image.Size;
							byte [] barr=(byte [])image.Value;

                            //Write the byte array to file
							file.Write(barr,0,barr.Length);
						}
				
					}	
                    //close the file
					file.Close();
				}
				else
				{   //If image size is zero display the message
					System.Windows.Forms.MessageBox.Show("Image Does not exists");
					return false;
				}
			}
			catch(Exception e)
			{
				//Display any error that occured
				System.Windows.Forms.MessageBox.Show(e.Message);
				return false;
			}
			return true;
			
		}
        
		/**********************************************************************************
		 * This function updates the new image for selected product to the database
		 * in following steps:
		 * 1. Create a command object and specify the SQL string to call the stored procedure.
		 * 2. Set the 'SPPrmsLOB' property to true 
		 * 3. Create parameters to be passed to stored procedure.
		 * 4. Open the image file. Write the data bytes from file to image parameter using 
		 *    AppendChunk method
		 * 5. Append the parameters to command object
		 * 6. Execute the command to update the image to database
		 * *********************************************************************************/
		public bool updateProductImage(string p_productid,string p_filename)
		{  
			try
			{  
				//create a copy of selected image file because it is already being used by
				//picture box for new image
				System.IO.File.Copy(p_filename,System.Windows.Forms.Application.StartupPath +
                                                                       "/datafile.gif",false);
                
				//Convert productid from string to integer
				int pid=Int32.Parse(p_productid);
			
				//Specify SQL statement to call stored procedure using ODBC escape sequence
				string strSQL="{Call setproductimage(?,?) }";
				
				//Create ADODB command object
				ADODB.Command cmd=new ADODB.Command();

				//Set command object's active connection to open connection
				cmd.ActiveConnection=m_conn;
				
				//Set the 'SPPrmsLOB' property to true. This is required to tell the
				//provider that a LOB parameter is being passed
				ADODB.Properties properties;

				//Get the command properties into ADO properties object
				properties=cmd.Properties;

                //Obtain an enumerator of the properties
				System.Collections.IEnumerator ienum=properties.GetEnumerator();
				ADODB.Property singleprop;

				while(ienum.MoveNext())  //iterate through enumerator
				{
					//Get the current property into Property object
					singleprop=(ADODB.Property)ienum.Current;

					//Get the name of current property
					string propname= singleprop.Name;

					//if it is 'SPPrmsLOB' set its value to true
					if(propname.Equals("SPPrmsLOB"))
						singleprop.Value=true;
				}

				//Set the command type to text
				cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;

				//Set the command object's text to SQL statement
				cmd.CommandText=strSQL;
                
				//Open the new image file for reading
				System.IO.FileStream file=new System.IO.FileStream(System.Windows.Forms.Application.StartupPath +
                                                               "/datafile.gif",System.IO.FileMode.Open);
				
				//Create a byte array with lenth equal to filesize
				byte []barr=new byte[file.Length];

                //Create parameter for product id
				ADODB._Parameter productid = cmd.CreateParameter("pid",ADODB.DataTypeEnum.adNumeric,
					                        ADODB.ParameterDirectionEnum.adParamInput,20,pid);
				
				//Create parameter for product image
				ADODB._Parameter pimage = cmd.CreateParameter("pimage",ADODB.DataTypeEnum.adLongVarBinary,
					                     ADODB.ParameterDirectionEnum.adParamInput,(int)file.Length,"");
				
				//if file is readable
				if(file.CanRead)
				{  
					//Read the file into byte array
					file.Read(barr,0,barr.Length);

					//Append the byte array to image parameter
					pimage.AppendChunk(barr);
				}

				//Append the parameters to command object
				cmd.Parameters.Append(productid);
				cmd.Parameters.Append(pimage);
				
				//Close the image file
				file.Close();
				
                //Execute the command to update the image
				object recs;
				object sqa=pid;
				cmd.Execute(out recs,ref sqa,0);  
                
				//Set SPPrmsLOB property to false
				//Reset the enumerator containing command properties to initial position
				ienum.Reset();
				while(ienum.MoveNext())  //iterate through enumerator
				{
					//Get the current property in to Property object
					singleprop=(ADODB.Property)ienum.Current;

					//Get the name of current property
					string propname= singleprop.Name;

					//if it is 'SPPrmsLOB' set its value to true
					if(propname.Equals("SPPrmsLOB"))
						singleprop.Value=false;
				}
				
				//Delete the temporary copy of image file
				System.IO.File.Delete(System.Windows.Forms.Application.StartupPath +"/datafile.gif");
				
			}
			catch(Exception e)
			{
				//Display any errors if occured
				System.Windows.Forms.MessageBox.Show(e.Message);

				//Delete temporary image file
				System.IO.File.Delete(System.Windows.Forms.Application.StartupPath +"/datafile.gif");
				return false;
			}
			return true;	//successful completion
		}

	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区三区在线播放 | 日韩毛片高清在线播放| 欧美亚洲综合另类| 99视频精品全部免费在线| 国产a级毛片一区| 风间由美一区二区av101| 成人高清免费在线播放| 色婷婷久久一区二区三区麻豆| 成人av在线观| 色综合夜色一区| 欧美亚洲禁片免费| 4438x成人网最大色成网站| 在线播放中文一区| 精品理论电影在线| 欧美国产欧美综合| 亚洲精品美腿丝袜| 亚洲电影视频在线| 韩国精品主播一区二区在线观看 | 欧美男人的天堂一二区| 这里只有精品99re| 国产欧美日本一区视频| 亚洲精品中文字幕乱码三区| 日韩精品欧美精品| 成人综合婷婷国产精品久久| 91亚洲精品久久久蜜桃网站| 91精品国产综合久久久久久久久久 | 91原创在线视频| 欧美色视频在线| 久久久久久综合| 一区二区三区在线免费观看| 日本麻豆一区二区三区视频| 成人在线视频一区二区| 欧美日韩专区在线| 欧美片在线播放| 国产网站一区二区| 午夜久久久久久久久| 国产麻豆精品久久一二三| 91国产免费观看| 久久综合色综合88| 亚洲国产精品久久一线不卡| 国产一区二区成人久久免费影院 | fc2成人免费人成在线观看播放| 一本色道亚洲精品aⅴ| 久久综合色综合88| 日韩高清不卡一区| 99re成人精品视频| 久久久三级国产网站| 亚洲成人av资源| 91最新地址在线播放| 欧美精品一区二区在线播放 | 国产一区二区三区视频在线播放| 不卡一区二区三区四区| 欧美麻豆精品久久久久久| 国产精品久久久久久久久快鸭| 琪琪一区二区三区| 欧美午夜免费电影| 亚洲裸体在线观看| 成人动漫视频在线| 国产色产综合色产在线视频| 久久成人综合网| 91精品国产日韩91久久久久久| 1区2区3区精品视频| 久久国产精品免费| 日韩一二三区视频| 日本大胆欧美人术艺术动态| 欧美久久一区二区| 亚洲bt欧美bt精品| 欧美日韩精品高清| 午夜欧美视频在线观看| 色婷婷国产精品综合在线观看| 国产精品视频在线看| av在线播放不卡| 亚洲天堂av一区| 一本大道久久a久久精品综合| 18成人在线视频| 色婷婷av一区二区三区大白胸 | 亚洲第一电影网| 欧美色图天堂网| 五月天激情小说综合| 6080国产精品一区二区| 日韩极品在线观看| 日韩精品一区二区三区swag| 蜜臀av一区二区在线免费观看| 欧美一级在线免费| 久久精品国产第一区二区三区| 精品国产电影一区二区| 国产一区二区精品久久| 国产精品日产欧美久久久久| 成人av资源在线| 一区二区三区免费| 这里只有精品电影| 国产精品一区二区在线播放| 国产精品成人一区二区艾草| 欧洲精品视频在线观看| 视频一区视频二区中文| 精品1区2区在线观看| av电影一区二区| 一区二区三区四区高清精品免费观看| 欧美日韩中文另类| 韩国毛片一区二区三区| 亚洲欧洲av在线| 91精品欧美综合在线观看最新| 精品一区二区久久| 中文字幕一区日韩精品欧美| 99精品视频在线免费观看| 婷婷久久综合九色综合绿巨人| 欧美mv日韩mv亚洲| 99国产一区二区三精品乱码| 午夜av区久久| 国产精品卡一卡二| 日韩午夜在线播放| 91看片淫黄大片一级| 国产馆精品极品| 五月天视频一区| 中文字幕字幕中文在线中不卡视频| 91精品一区二区三区久久久久久 | 欧美日韩免费视频| 国产成人精品三级麻豆| 亚洲一区二区三区中文字幕| 久久免费视频一区| 在线不卡欧美精品一区二区三区| 成人av集中营| 国产一区二区精品久久99| 午夜精品影院在线观看| 国产精品国产三级国产普通话99| 91精品国产91综合久久蜜臀| 91视频免费观看| 国产一区二区三区在线观看精品| 亚洲美女屁股眼交| 国产精品久久久久影视| 精品国产免费一区二区三区香蕉| 欧美视频一区二区三区四区 | 日韩一区二区三区在线视频| 91片在线免费观看| 成人一区二区三区视频| 国产麻豆精品95视频| 久久精品国内一区二区三区| 亚洲国产婷婷综合在线精品| 亚洲乱码国产乱码精品精可以看 | av网站一区二区三区| 狠狠色丁香久久婷婷综| 秋霞午夜av一区二区三区| 丝袜美腿亚洲综合| 日韩精品一二三| 男人的j进女人的j一区| 肉色丝袜一区二区| 天天操天天综合网| 石原莉奈在线亚洲二区| 性久久久久久久久| 欧美aⅴ一区二区三区视频| 亚洲国产一二三| 午夜视频在线观看一区| 亚洲成人中文在线| 免费欧美日韩国产三级电影| 日韩激情视频在线观看| 日韩高清中文字幕一区| 日日夜夜精品免费视频| 蜜桃视频一区二区三区在线观看| 另类欧美日韩国产在线| 国产真实乱偷精品视频免| 国产精品中文字幕一区二区三区| 国产 日韩 欧美大片| 99久久久久免费精品国产 | 午夜视频在线观看一区二区三区| 亚洲成人av福利| 麻豆视频一区二区| 国产一区二区三区四区五区美女| 国产99精品国产| 在线免费观看成人短视频| 欧美老女人第四色| 久久嫩草精品久久久精品一| 国产精品人成在线观看免费 | 久国产精品韩国三级视频| 国产成人av影院| 色乱码一区二区三区88| 欧美一级日韩免费不卡| 国产日韩欧美激情| 夜夜精品视频一区二区 | 精品污污网站免费看| 日韩欧美的一区| 国产精品国产三级国产有无不卡 | 日韩欧美国产一区二区在线播放| 久久亚洲一级片| 亚洲一区二区综合| 久久er99精品| 色婷婷精品大视频在线蜜桃视频| 日韩一区二区视频| 亚洲欧美日韩中文播放| 久久电影网电视剧免费观看| 波多野结衣一区二区三区 | 自拍视频在线观看一区二区| 亚洲va在线va天堂| 成人丝袜高跟foot| 欧美一区二区三区啪啪| 国产精品美女久久久久久久久| 免费看日韩a级影片| 91性感美女视频| 久久精品夜色噜噜亚洲aⅴ| 天天av天天翘天天综合网色鬼国产 | 麻豆91小视频|