使用NPOI添加excel內容失敗(在現有excel檔案后添加數據失敗)

通過click事件,在檔案中新建d:\a1.xlsx這個文件,也可以保存數據;但是重新打開,添加數據失敗!
下面使用了兩種NPOI方式,全部失敗!!沒有報錯,也沒發現問題所在。
執行后都是只能顯示如下內容,也就是說可以新建並且存入,但是,但是,但是在現有excel后添加數據失敗,請大家幫忙看看,指教!
图片说明

 private void button51_Click(object sender, EventArgs e)
        {

            NPOI.XSSF.UserModel.XSSFWorkbook book = new NPOI.XSSF.UserModel.XSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet = book.CreateSheet("test_01");

            if (rowIndex == 1)       //執行一次
            {
                NPOI.SS.UserModel.IRow headerRow = sheet.CreateRow(0);
                headerRow.CreateCell(0).SetCellValue("序號");
                headerRow.CreateCell(1).SetCellValue("測試一");
                headerRow.CreateCell(2).SetCellValue("測試二");
                headerRow.CreateCell(3).SetCellValue("測試三");
                headerRow.CreateCell(4).SetCellValue("測試四");

                NPOI.SS.UserModel.IRow dataRow = sheet.CreateRow(rowIndex);
                dataRow.CreateCell(0).SetCellValue(rowIndex.ToString());
                dataRow.CreateCell(1).SetCellValue(userControl_station_status6.textbox94_int.ToString());
                dataRow.CreateCell(2).SetCellValue(userControl_station_status8.textbox93_int.ToString());
                dataRow.CreateCell(3).SetCellValue(userControl_station_status10.textbox92_int.ToString());
                dataRow.CreateCell(4).SetCellValue(userControl_station_status12.textbox91_int.ToString());
                fs = new FileStream(@"d:\a1.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

                book.Write(fs);
                //fs.Flush();
                headerRow = null;
                dataRow = null;
                sheet = null;
                book.Close();
                book = null;
                book = null;
                book = null;
                fs.Close();
                fs.Dispose();
                 fs = null;
            }
            else
            {
                FileStream fs = new FileStream(@"d:\a1.xlsx", FileMode.Open, FileAccess.ReadWrite);
                XSSFWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(fs);
                ISheet sheet2 = workbook.GetSheetAt(0);//获取工作表
                IRow row = sheet2.GetRow(0); //得到表头
                row = sheet2.CreateRow((sheet2.LastRowNum + 1));//在工作表中添加一行

                row.CreateCell(0).SetCellValue("ftfyfghghvgh");
                row.CreateCell(1).SetCellValue("ftfyfghghvgh");             
                workbook.Write(fs);//写入文件
                workbook.Close();
                workbook = null;
                fs.Close();
                fs.Dispose();
                fs = null;
            }
       }









 private void button51_Click(object sender, EventArgs e)
        {

            NPOI.XSSF.UserModel.XSSFWorkbook book = new NPOI.XSSF.UserModel.XSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet = book.CreateSheet("test_01");

            if (rowIndex == 1)       //執行一次
            {
                NPOI.SS.UserModel.IRow headerRow = sheet.CreateRow(0);
                headerRow.CreateCell(0).SetCellValue("序號");
                headerRow.CreateCell(1).SetCellValue("測試一");
                headerRow.CreateCell(2).SetCellValue("測試二");
                headerRow.CreateCell(3).SetCellValue("測試三");
                headerRow.CreateCell(4).SetCellValue("測試四");

                NPOI.SS.UserModel.IRow dataRow = sheet.CreateRow(rowIndex);
                dataRow.CreateCell(0).SetCellValue(rowIndex.ToString());
                dataRow.CreateCell(1).SetCellValue(userControl_station_status6.textbox94_int.ToString());
                dataRow.CreateCell(2).SetCellValue(userControl_station_status8.textbox93_int.ToString());
                dataRow.CreateCell(3).SetCellValue(userControl_station_status10.textbox92_int.ToString());
                dataRow.CreateCell(4).SetCellValue(userControl_station_status12.textbox91_int.ToString());
                fs = new FileStream(@"d:\a1.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

                book.Write(fs);
                //fs.Flush();
                headerRow = null;
                dataRow = null;
                sheet = null;
                book.Close();
                book = null;
                book = null;
                book = null;
                fs.Close();
                fs.Dispose();
                 fs = null;
            }
            else
            {



                NPOI.SS.UserModel.IRow dataRow = sheet.CreateRow(rowIndex);
                dataRow.CreateCell(0).SetCellValue(rowIndex.ToString());
                dataRow.CreateCell(1).SetCellValue(userControl_station_status6.textbox94_int.ToString());
                dataRow.CreateCell(2).SetCellValue(userControl_station_status8.textbox93_int.ToString());
                dataRow.CreateCell(3).SetCellValue(userControl_station_status10.textbox92_int.ToString());
                dataRow.CreateCell(4).SetCellValue(userControl_station_status12.textbox91_int.ToString());
                fs = new FileStream(@"d:\a1.xlsx", FileMode.Append);//写入流
                book.Write(fs);
                dataRow = null;
                sheet = null;
                book.Close();
                book = null;
                book = null;
                book = null;
                fs.Close();
                fs.Dispose();
                fs = null;
            }


            rowIndex++;


        }
    }

0

5个回答

   //  方法 1
                FileStream fs = new FileStream(@"d:\a1.xlsx", FileMode.Open, FileAccess.ReadWrite);
              //  XSSFWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(fs);
                XSSFWorkbook  workbook = new XSSFWorkbook(fs);
                ISheet sheet2 = workbook.GetSheetAt(0);//获取工作表
                IRow row = sheet2.GetRow(0); //得到表头
                row = sheet2.CreateRow((sheet2.LastRowNum + 1));//在工作表中添加一行

                row.CreateCell(0).SetCellValue((sheet2.LastRowNum).ToString());
                row.CreateCell(1).SetCellValue(userControl_station_status6.textbox94_int.ToString());
                row.CreateCell(2).SetCellValue(userControl_station_status6.textbox93_int.ToString());
                row.CreateCell(3).SetCellValue(userControl_station_status6.textbox92_int.ToString());
                row.CreateCell(4).SetCellValue(userControl_station_status6.textbox91_int.ToString());

                FileStream fs2 = new FileStream(@"d:\a1.xlsx", FileMode.Create, FileAccess.Write);
                workbook.Write(fs2);

              //  workbook.Write(fs);//写入文件
                workbook.Close();
                workbook = null;
                fs.Close();
                fs.Dispose();
                fs = null;

                fs2.Close();
                fs2.Dispose();
                fs2 = null;

使用兩次“流”就能實現。分數給自己吧!

0

上面有一些錯別字,複述下
通過click事件,在檔案中新建d:\a1.xlsx這個文件(成功), 也可以通過FileStream 保存數據(成功);
重新打開d:\a1.xlsx,並且在後面添加一行新的數據(失敗)~~試了兩種方式都不行啊

0
0
martin_tang
martin_tang 新建並且添加都可以,但是使用類似 append的形式重新打開並且添加內容時候不行啊!
大约 3 年之前 回复

有人知道嗎??
頭痛啊!

0

在現有excel后添加數據失敗?是不是rowIndex没有更新,又从1开始了?你需要先获取当前文档中有多数行

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
登入界面檢索數據失敗
大家好﹗小弟我有一個問題不知如何解決﹐程式運行先調用SystemData:=TSystemData.Create(Application)連上后台然后彈出登入界面﹐如果帶參數就不能檢索到數據﹐其中登入控件代碼如下﹕rnprocedure TLoginForm.ButtonOkClick(Sender: TObject);rnbeginrn LoginName:=Edit1.Text;rn LoginPassword:=Edit2.Text;rn tryrn if length(Edit1.Text)=0 thenrn FormHit.ShowModal ;rn if inputtimes <= 3 thenrn beginrn with SystemData.QueryUser Dorn beginrn close;rn DatabaseName:='pberp';rn with sql dorn beginrn clear;rn add('select * from em_use where fact_no=:fact and use_id=:name and rn password=:pass_word');rn //add('select * from em_use where fact_no='+'888')如果這樣直接設置可以﹐但rn 多加參數會提示無效欄位。rn end;rn ParamByName('factno').AsString := '888';rn ParamByName('name).AsString := LoginName;rn ParamByName('pass_word').AsString := LoginPasswordrnrn open ;rn ShowMessage(inttostr(SystemData.QueryUser.RecordCount)) ;rn end;rn inputtimes:=inputtimes+1;rn end;rn if SystemData.QueryUser.RecordCount<>1 thenrn beginrn if inputtimes<3 thenrn beginrn FormHit.ShowModal;rn Edit1.Text:='';rn Edit2.Text:='';rn Edit1.SetFocus;rn endrn elsern beginrn LoginFlag:=0;rn FormError.ShowModal ;rn close;rn end;rn end;rn SystemData.QueryUser.Close;rn SystemData.QueryLogin.Close;rnExceptrn on E:Exception dorn beginrn ShowMessage('數據庫連接失敗,請檢驗網絡連接是否正常');rn Application.Terminate;rn end;rnend;rnend;rn望大家不吝指點一下﹐多謝﹗
創建表失敗
執行下面的SQL語句創建表失敗,請問各位該如何解決?謝謝!!rnrnCREATE table enrollsrn(sno numeric(6,0) not null,rncno char(4) not null,rngrade int rnprimary key (sno,cno)rnforeign key (sno) references students(sno)rnforeign key (cno) references courses(cno)rncheck((grade is null)or(grade between 0 and 100)))rnrn錯誤提示:More than one column FOREIGN KEY constraint specified for column 'grade', table 'enrolls'. rn
outlook2003打開失敗
我的outlook在打開時提示:“無法啟動Microsoft office outlook .無法打開outlook窗口。無法打開文件夾集合。服務器不可用。如果情況依舊,請與系統管理員聯系。”我用域用戶卸載重新安裝了問題依舊,但用本機管理進去可以打開,請問這是什麼問題呀,怎麼解決呢,急死了都弄了一天了,還是沒有辦法,請哪位高手幫忙解決一下,在線等
CrystalDecisions.CrystalReports.Engine.LogOnException: 登入失敗。
using System;rnusing System.Collections;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Web;rnusing System.Web.SessionState;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.HtmlControls;rnusing CrystalDecisions.Shared;rnusing CrystalDecisions.CrystalReports.Engine;rnrnnamespace TESTrnrn public class WebForm2 : System.Web.UI.Pagern rn protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;rn rn private void Page_Load(object sender, System.EventArgs e)rn rn TableLogOnInfo logOnInfo = new TableLogOnInfo();rn ReportDocument oRpt = new ReportDocument();rnrn oRpt.Load("C:\\Inetpub\\wwwroot\\TEST\\CrystalReport1.rpt");rn rn logOnInfo.ConnectionInfo.ServerName = "SFIS-KS";rn logOnInfo.ConnectionInfo.DatabaseName = "MES_KS";rn logOnInfo.ConnectionInfo.UserID = "MES_KS";rn logOnInfo.ConnectionInfo.Password = "MES_KS";rn rn oRpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);rn rn CrystalReportViewer1.ReportSource = oRpt;rn CrystalReportViewer1.DataBind();rn rnrn #region Web Form Designer generated codern override protected void OnInit(EventArgs e)rn rn InitializeComponent();rn base.OnInit(e);rn rn rn private void InitializeComponent()rn rn this.Load += new System.EventHandler(this.Page_Load);rnrn rn #endregionrn rnrnHelp!!!!!
編譯失敗
http://sourceforge.net/projects/pcp/rnrn有先 configure 再makernrnrn編譯上面代碼出現下面錯誤訊息rnrnmake 出現下面錯誤訊息rnrnMaking all in lapackrnmake[1]: Entering directory `/home/shihyu/pcp-2.2/lapack'rnmake[2]: Entering directory `/home/shihyu/pcp-2.2'rnmake[2]: Leaving directory `/home/shihyu/pcp-2.2'rnc -o lapack.o lapack.frnmake[1]: c: Command not foundrnmake[1]: [lapack.o] Error 127 (ignored)rnrm -f liblapack.arnar cru liblapack.a lapack.ornar: lapack.o: No such file or directoryrnmake[1]: *** [liblapack.a] Error 1rnmake[1]: Leaving directory `/home/shihyu/pcp-2.2/lapack'rnmake: *** [all-recursive] Error 1rnrn謝謝
添加唯一性約束失敗
為一個新表的一個字段(ID)添加一個唯一性約束,但不能添加,插入語句如下:rnalter table student add constraint only_one unique (id);rn[b]所報錯如下:[/b]rn第1行出現錯誤:rnORA-55610:針對歷史記錄跟蹤表的DDL語句無效
用AOD導入excel時失敗?
我的連接字符串conn.ConnectionString 為:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\test.xls;Persist Security Info=Falsernrn 為何提示"無法出現資料庫格式"? rn
usb wirtefile失敗
using System;rnusing System.Collections.Generic;rnusing System.Text;rnusing System.Runtime.InteropServices;rnusing System.ComponentModel;rnusing System.Windows.Forms;rnrnnamespace usbwritefilernrn class Programrnrn rn int HidHandle = -1;rn public const uint GENERIC_READ = 0x80000000;rn public const uint GENERIC_WRITE = 0x40000000;rn public const uint FILE_SHARE_READ = 0x00000001;rn public const uint FILE_SHARE_WRITE = 0x00000002;rn public const int OPEN_EXISTING = 3;rn //獲取設備文件rn [DllImport("kernel32.dll", SetLastError = true)]rn private static extern int CreateFile(rn string lpFileName, // file namern uint dwDesiredAccess, // access modern uint dwShareMode, // share modern uint lpSecurityAttributes, // SDrn uint dwCreationDisposition, // how to creatern uint dwFlagsAndAttributes, // file attributesrn uint hTemplateFile // handle to template filern );rn [DllImport("Kernel32.dll")]rn private static extern bool ReadFile(rn IntPtr hFile,rn byte[] lpBuffer,rn uint nNumberOfBytesToRead,rn ref uint lpNumberOfBytesRead,rn IntPtr lpOverlappedrn );rn [DllImport("Kernel32.dll", SetLastError = true)]rn private static extern bool WriteFile(rn IntPtr hFile,rn byte[] lpBuffer,rn uint nNumberOfBytesToWrite,rn ref uint lpNumberOfBytesWritten,rn IntPtr lpOverlappedrn );rn [DllImport("kernel32.dll")]rn private static extern bool CloseHandle(rn IntPtr hObjectrn );rn //-------------------------------------------------------------------------------- rn IntPtr hFile;rn private const Int32 INVALID_HANDLE_VALUE = -1;rn private const int USB_WRITENUM = 8;rn private const int USB_READNUM = 8;rn private byte[] m_rd_data = new byte[USB_READNUM];rn public byte[] rd_datarn rn get return m_rd_data; rn set m_rd_data = value; rn rn private byte[] m_wr_data = new byte[USB_WRITENUM];rn public byte[] wr_datarn rn get return m_wr_data; rn set m_wr_data = value; rn rn public int OnInitUSB(string DeviceName)rn rn HidHandle = CreateFile(rn DeviceName,rn GENERIC_READ,// | GENERIC_WRITE,//讀寫,或者一起rn FILE_SHARE_READ,// | FILE_SHARE_WRITE,//共享讀寫,或者一起rn 0,rn OPEN_EXISTING,rn 0,rn 0);rn if (HidHandle == -1)rn rn return 0;rn rn elsern rn return 1;rn rn rn public bool USBDataRead()rn rn uint read = 0;rn return ReadFile(hFile, m_rd_data, (uint)USB_READNUM, ref read, IntPtr.Zero);rn rn public bool USBDataWrite()rn rn uint bytesWritten = 0;rn byte[] buffer = new byte[] 0x02, 0x02, 0x00 ;rn bool status = WriteFile((IntPtr)HidHandle, buffer, 8, ref bytesWritten, IntPtr.Zero);rn if (!status)rn rn int errorCode = Marshal.GetLastWin32Error();rn string errorMessage = new Win32Exception(errorCode).Message;rn Console.WriteLine(errorCode + ":" + errorMessage);rn MessageBox.Show(errorCode + ":" + errorMessage);rn return false;rn rn elsern rn Console.WriteLine(bytesWritten.ToString());rn return true;rn rn rn public void CloseConnection()rn rn if (hFile.ToInt32() != INVALID_HANDLE_VALUE)rn rn CloseHandle(hFile);rn hFile = IntPtr.Zero;rn rn rnrn static void Main(string[] args)rn rn Program p = new Program();rn p.OnInitUSB("\\\\?\\hid#vid_046d&pid_0a29&mi_03&col02#7&ca16861&0&0001#4d1e55b2-f16f-11cf-88cb-001111000030");rn p.USBDataWrite();rn Console.ReadKey();rn rnrn rn rnrnrn大家好.上面是我写的一个关于给usb设备发送数据的程序,但是现在出现了问题,createfile可以成功,可以获取到句柄,但是到writefile发送数据的时候,总是出现参数无效rn请问大家该怎么解决?rn谢谢!rn
ASPNET登入失敗
連接字串如下:rn ConnectString=Server=localhost;DataBase=northwind;Integrated scurity=SSPI"rn錯誤:rnASPNET登入失敗.rnrn我分析:rn這是一個信任連接,可能與我的server設置有關.但不知該如何設置.rn註:我設置好像是混合連接方式
VC向MYSQL輸入數據失敗
程序執行 根據返回數值判斷 mysql_query( conn,str)執行失敗, m_Order 是一個編輯框的成員變量。rnrn相關代碼:rnCString str="insert into table1 (' order') values ( 'm_Order' )";rnmysql_query( conn ,str);rnrn為什么寫不進去呢?
微信支付簽名失敗
我用的微信的demo,微信支付的時候所有參數都正確,但是就是第二次簽名的時候失敗,找了好久才發現有個什麼沙箱環境,真尼瑪的b了狗。。。 請先參考前一篇博客:微信支付生成paySign失敗  ,確認問題是否和我的一樣。 最後修改簽名的加密方式就行啦  ...
informix insert中文失敗
我安裝了informix client skd 3.0 , 用C#引用了IBM.Data.Informix.dll,rn能連接查詢數據,但是insert中文简体就出错,db_locale和CLIENT_LOCALE都rn是台湾的繁体字,有什么办法可以解决这个问题吗?rn有没有想jdbc中的IFX_USE_STRENC=TRUE;这样解决问题的函数?
MAPI 呼叫 'OpenMsgStore' 失敗
MAPI 呼叫 'OpenMsgStore' 失敗,錯誤為: rn無法使用 Microsoft Exchange Server 電腦。可能是網路發生問題,或是 Microsoft Exchange Server 電腦目前因維護而關閉。rnMAPI 提供者失敗。rnMicrosoft Exchange Server Information Storern識別碼: 8004011d-0526-00000000
CB2009 StringToHex運行失敗
[code=C/C++]rnvoid __fastcall TForm1::FormCreate(TObject *Sender)rnrn String b = L"為人民服務";rn String c;rn for(int i=0;i
數據庫加載失敗
Oracle數據庫加載失敗,提示歸檔日志文件有毀(可能是昨日公司停電服務器未正常關機造成)請各位高手救救小弟,解決後定高分相送,在此先謝過了。
sql2000連接失敗
我在本地測試jsp.出現下面錯誤,怎麼回事啊?,高手大大們rn++++++++++++++++++++++++++++++++++++++rnjava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.rn at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)rn at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)rn at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown rnrn++++++rn驅動都已經放好,rn連接語句:rnClass.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();rn Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://172.16.21.22:1433;DatabaseName=jspdev","jspdev","jspdev");
增加記錄失敗......
我有一個表gzvar_detail,其中gzvar_emp_id,gzvar_acc_period,gzvar_item為關鍵字﹐我想用下面語句把插入一批數據。rninsert into gzvar_detail(gzvar_emp_id,gzvar_acc_period,gzvar_item,gzvar_type_id)rnselect employee_id,'2002-04',75,1rnfrom employeernrn希望有的就不插入﹐沒有就插入﹐可是他遇到存在計錄就自動中斷﹐請問要加什么參數拷才可以滿足上面需要.雖然可以寫存儲過程但為這樣一個小問題大動手腳沒必要啊.rn
vs2010 發布失敗
為什麼vs2010發布失敗,提示很多空間引用出錯問題。
WSUS2.0安裝失敗
WSUS2-KB919004-x86.exernrn在安裝到selfupdate的階段出現錯誤,自動反安裝退出rnrnMicrosoft Windows Server Update Services 無法安裝 Selfupdate MSI。 如需相關資訊,請參閱安裝記錄 "C:\Program Files\Update Services\LogFiles\WSUSSetup_070425_1413.log"。rnrn。rn。rn。rn2007-04-25 14:13:42 Success MWUSSetup Copying installation settings to the registryrn2007-04-25 14:13:42 Success MWUSSetup Installing MSUS...rn2007-04-25 14:13:42 Success MWUSSetup Installing MWUS With Command Line SETUP_EXE=1 WUS_INSTALLMODE="128" AUTHENTICATED_USERS="NT AUTHORITY\Authenticated Users" CONTENT_LOCAL="1" SQLINSTANCE_NAME="%computername%" CUSTOMACTION_LOG="C:\Program Files\Update Services\LogFiles\WSUSCa_070425_1413.log" REPLICA_PARENT_PORTrn2007-04-25 14:13:43 Success CustomActions.Dll .Net framework path: C:\WINNT\Microsoft.Net\Framework\v1.1.4322rn2007-04-25 14:13:47 Success CustomActions.Dll Creating WSUS Administrators user grouprn2007-04-25 14:13:48 Success CustomActions.Dll Successfully created WSUS Administrators user grouprn2007-04-25 14:14:54 Success CustomActions.Dll Successfully configured the databasern2007-04-25 14:14:55 Info IISCustomAction Performing Setup Action, Command /Install rn2007-04-25 14:16:59 Info IISCustomAction Command /Install Succeededrn2007-04-25 14:17:29 Success CustomActions.Dll Successfully created shortcut for WSUS websitern2007-04-25 14:17:31 Success MWUSSetup WSUS Installed Successfullyrn2007-04-25 14:17:31 Success MWUSSetup MWUS is installed successfully. Performing post MWUS install operationsrn2007-04-25 14:17:31 Success MWUSSetup Installing Client Self Update Binariesrn2007-04-25 14:17:52 Error MWUSSetup Selfupdate MSI Installation Failed. (Error 0x80070643: 安裝時發生嚴重錯誤。)rn2007-04-25 14:17:52 Error MWUSSetup InstallSelfUpdateMsi failed. (Error 0x80070643: 安裝時發生嚴重錯誤。)rn2007-04-25 14:17:52 Error MWUSSetup Client Selfupdate files installation failed (Error 0x80070643: 安裝時發生嚴重錯誤。)rn2007-04-25 14:17:52 Error MWUSSetup PerformInstall failed (Error 0x80070643: 安裝時發生嚴重錯誤。)rn2007-04-25 14:17:52 Success MWUSSetup Rolling back Installationrn2007-04-25 14:17:52 Success MWUSSetup WSUS Server installation failed. You can look at C:\Program Files\Update Services\LogFiles\WSUSSetup_070425_1413.log file to determine the cause of the failurern2007-04-25 14:18:20 Success MWUSSetup Uninstalling MWUSrn。rn。rn。rnrn什么原因?rn
oracle dba登入失敗!!!!!
下午好!rn 今天我的後台數據庫聯接失敗,用dba登入提示 ORA-12560:TNS:協定介面程式錯誤,讓我不知所措rn還望在線高手教導,謝!!
連結 Mysql 失敗
import java.sql.*;rnpublic class dbtest rn public static void main(String[] args) rn Connection con = null;rn try rn Class.forName("org.gjt.mm.mysql.Driver").newInstance();rn System.out.println("JDBC Driver loaded");rn con = DriverManager.getConnection("jdbc:mysql://localhost/mysql?user=root&password=pass");rn System.out.println("Database connected");rn catch (ClassNotFoundException cnfe) rn System.out.println(" Could Not Locate Driver");rn catch (Exception e) rn System.out.println(" Unknown error1 ");rn finally rn tryrn if(con!=null) con.close();rn catch (Exception e) rn System.out.println(" Unknown error2 ");rn rn rnrn rnrnrn++++++++++++++++++++++++++rn結果 ; rnJDBC Driver loadedrn Unknown error1 rnrn但是 我的 Mysql 已經運行.rn不知道是甚麼原因?rn
還原 master 數據庫失敗,求救...
我用 master.bak 還原數據庫的時候出現類似於"RESTORE DATABASE 必須使用於單一使用者模式" 的錯誤,但是其他數據庫還原都正常,請問怎麼才算是單一使用者模式?
爲何instert語句失敗?
表裏有50個字段,我寫insert語句,執行成功 ,也不報錯!但是居然後臺數據庫不能插入記錄!rn有人遇到過這種情況嗎??是什麽原因?rn高手指點,要代碼的時候,我再發代碼1
Server.CreateObject 的呼叫失敗,急!急!急!
調用COM時出現如下錯誤,請各位大俠幫忙,已經好多天了,急急!rn錯誤類型:rn伺服器物件, ASP 0178 (0x80070005)rn當檢查使用權限時 Server.CreateObject 的呼叫失敗。拒絕存取此物件。rn/shingtak/Menu.asp, line 62rnrnrn
新增記錄存儲失敗
SQL Server2000后台,Powerbuilder開發工具在服務器上運行正常﹐但在客戶機上通過ODBC連接后新增記錄失敗。rn煩請高手指點一下﹐多謝﹗﹗
郵件自動發送失敗???
請教各位大俠,我用這個怎麼收不到郵件呢,網頁顯示成功?rn<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>rnrn<%rnSet mail = Server.CreateObject("cdonts.newmail") rnmail.From = "reed.chen@deltadg.com.cn" '發件人Email rnrnmail.To="reed.chen@deltadg.com.cn"rnmail.Subject = "test send email" '信件主題 rnmail.Body = "test send email!" rnrnrnmail.Send ("dgex04") '這是公司的郵件服務器名稱rnset mail = nothingrnresponse.write "發送成功!"rnrn%>rnrn Untitled Documentrn rnrnrnrnrnrn
OpenSCManager 開啟失敗 ERROR_ACCESS_DENIED
用administrator權限CreateService 創建一個Guest帳戶的服務 ,rnex:CreateService(...,"AAA",SERVICE_WIN32_OWN_PROCESS,rnSERVICE_DEMAND_START,...,".\\Guest",0);rnrn但是當使用Guest帳戶登入時 , 使用OpenSCManager 卻出現存取失敗 ,rn似乎是權限的問題,ex:OpenSCManager(0,0,SC_MANAGER_CONNECT);rnrn要如何解決才能讓Guest 使用 AAA 服務 ? 還少哪些相關設定嗎?rn請大家幫一下忙~~ 謝謝,小弟感激阿.
GPG公匙導入失敗解決
GPG公匙導入失敗解決 按照本文檔描述的辦法,一定可以解決
SQL Server 2008帳號登入失敗
請問SQL Server是否可跟蹤出每個連接串的內容? rn因為有個程序沒源碼, 不知其連接SQL的連接串是什么, 想跟蹤出來然后進SQL進行相應的設置, 謝謝!
Oracle數據庫加載失敗
Oracle數據庫加載失敗,提示歸檔日志文件有毀(可能是昨日公司停電服務器未正常關機造成)請各位高手救救小弟,解決後定高分相送,在此先謝過了。rn我的庫是自動歸檔,請問如何用歸檔日志恢復還是另有方法重新生成歸檔日志?在等待!
神奇!!!Controller注入Service失敗
[b]Controller[/b]rn[code=java]package me.dack.core.controller;rnrnimport java.util.List;rnrnimport org.springframework.beans.factory.annotation.Autowired;rnimport org.springframework.stereotype.Controller;rnimport org.springframework.ui.ModelMap;rnimport org.springframework.web.bind.annotation.RequestMapping;rnrnimport me.dack.core.bean.Category;rnimport me.dack.core.service.CategoryService;rnrn@Controllerrnpublic class ColumnControllerrn rn @Autowiredrn private CategoryService categoryService;rn rn rn @RequestMapping(value="/back/main.do")rn public String toMain()rn rn return "main";rn rn rn @RequestMapping(value="/back/top.do")rn public String toTop()rn rn return "top";rn rn rn rn @RequestMapping(value="/back/left_column.do")rn public String toLeft_column(ModelMap model)rn List categorys = categoryService.getAllCategory();rn model.addAttribute("categorys", categorys);rn return "/column/left";rn rn rn @RequestMapping(value="/back/right_column.do")rn public String toRight_column()rn rn return "/column/right";rn rnrn[/code]rnrn[b]Service[/b]rn[code=java]package me.dack.core.service;rnrnimport java.util.List;rnrnimport org.springframework.stereotype.Service;rnrnimport me.dack.core.bean.Category;rnimport me.dack.core.dao.CategoryDao;rnimport javax.annotation.Resource;rnrn@Servicernpublic class CategoryServiceImpl implements CategoryServicernrn @Resourcern private CategoryDao categoryDao;rn rn public List getCategoryList(Category category) rn return categoryDao.getCategoryList(category);rn rnrn @Overridern public Category getCategoryById(Integer id) rn return categoryDao.getCategoryById(id);rn rnrn @Overridern public List getAllCategory() rn return categoryDao.getAllCategory();rn rnrnrn[/code]rnrn[b]springmvc.xml[/b]rn[code=java]rnrn rn rn rn rn rn rn rn rn rn rn rn rn[/code]rnrnrnapplication-context.xmlrn[code=java]rnrn rn rn rn rn rn rn[/code]rnrnjsprn[code=html]<%@ page language="java" contentType="text/html; charset=utf-8"rn pageEncoding="utf-8"%>rn<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>rnrnrnrn rn 网站后台管理系统HTML模板--模板之家 www.cssmoban.comrnrnrn rn rn rn rn rnrn <body>rn</body>rnrn[/code]rnrnrn求救啊 --------------------rn实在找不到在哪里的错误
windows-延誤寫入失敗!?!
以下錯誤是什麼錯誤?是什麼原因造成的?各路高手請看一下!!!rnrnwindows-延誤寫入失敗.rnwindows無法儲存檔案\device\harddisk volume2\windows\start menu\program\附件\...的所有資料,資料已遺失。這個錯誤可能是由你的電腦硬件或網絡失敗所造成。請嚐試在其它位置儲存這個檔案。rnrnrnPCCONFIG:rnOS:windows2000rnCPU:P3 866rnRAM:128Mrn安裝有以下軟件:rnOFFICE2000rnPHOTOSHOP 6.0英文版rnrnrn
編釈失敗 原因不明
rnCLASSPATH=/opt/svf_c2j/svfrserver.jar:/export/home1/svfje/web4pdf/svfjpd/lib/svf.jar:/opt/FJSVbcrnco/redist/ejb/ujiejbcl.jar:/app/bea/wlserver6.1/lib/j2ee12.jar:/opt/FJSVwebc/lib/uji.jar:rn/opt/FJSVbcco/lib/ujiejb.jar:/app/bea/wlserver6.1/lib/weblogic.jar:/app/bea/wlserver6.1/lib/wlepool.jar:rn/app/bea/wlserver6.1/lib/xmlx.jar:/app/bea/wlserver6.1/lib/mssqlserver4v65.jarrnrn編釈rn/app/bea/jdk131/bin/javac -d . -classpath $CLASSPATH:/export/home1/sinkin/aplweb/WEB-INF/crnlasses PMD06YILDF_Session.javarnPMD06YILDF_Session.java:6: 記号を解釈処理不能。rn記号: CLASS KONSB_CommonSessionBeanrn位置 : ejb 的packagernimport jp.co.shinkin.MBMS.CMON.ejb.KONSB_CommonSessionBean;rn ^rnPMD06YILDF_Session.java:17: 記号を解釈処理不能。rn記号: CLASS KONSB_CommonSessionBeanrn位置 : jp.co.shinkin.MBMS.RSMD.ejb.PMD06YILDF_Session 的CLASSrnpublic class PMD06YILDF_Session extends KONSB_CommonSessionBean
資料導出至txt失敗
SELECT [sysno],[prgno] INTO [TEXT;Database=D:].[55.txt] FROM [pu]rnrn上面的例子是書上寫的.我用的是 ADO連接的,但是執行上面的代碼發生錯誤!rn提示如下:rnSpecified owner name 'TEXT;Database=D:' either does not exist or you do not have permission to use it.rn===>各位有位有成功的導出例子,就是導出到 txt 的例子,rn謝謝!rnrn
Enterprise中注冊數據庫失敗
我有一台機器﹐上面裝有SQL Server﹐我在哪台機器的Enterprise中以SQL Server認証﹐帳戶為sa,注冊成功。而在另一台機器上裝有SQL Server的客戶端﹐以同樣方法注冊﹐出現ConnectionOpen(FileOpen())錯誤。 rnrn 能夠ping通,它會用\\.\pipe\sql\query去聯接還是用TCP/IP租監聽1433端口呢.rnrn 其中NT Server服務器以獨立服務器啟動并加入到hipro-dg組﹐它不是hipro-dg的成員﹐而我的client電腦現在加入hipro-dg,請問怎么樣設定。rn
windows -延遲寫入失敗
windows 無法存儲檔案 f:\system volume
HttpURLConnection POST失敗code=411
if(definition.debug)rn rn System.getProperties().put("proxySet", "true"); rn System.getProperties().put("proxyHost", proxyIp); rn System.getProperties().put("proxyPort", proxyPort);rn rn rn HttpURLConnection conn = null;rn rn conn = (HttpURLConnection) myUrl.openConnection();rn rn conn.setDoInput(true);rn conn.setDoOutput(true);rn conn.setConnectTimeout(20000);rn conn.setReadTimeout(20000);rn rn conn.setRequestMethod("POST");rn rn conn.setUseCaches(false); rn conn.setInstanceFollowRedirects(true);rn conn.setRequestProperty("Content-Length", String.valueOf(sendData.length));rn conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");rn conn.connect();rn rn int resCode = conn.getResponseCode();rn if (resCode == HttpURLConnection.HTTP_OK) rn rn //進不來,老是411 POST換成GET就可以成功返回200rn rn 怎麼辦?
printer的打印方法失敗原因
我的vb做了一個小數據庫,在打印msflexgrid控件的數據時用printer控件打印..但使用的時候失敗,不知道是什么原因.....請教一下高手們...rnPrivate Sub print_Click()rnDim usewidth As IntegerrnDim useheight As IntegerrnWith Printerrn .PaperSize = 9rn .Orientation = 2rn .ScaleMode = 6rn .FontBold = Truern .ScaleLeft = -20 rn .ScaleTop = -25 rn .ScaleWidth = 297 rn .ScaleHeight = 210 rn usewidth = .ScaleWidth - 40 rn useheight = .ScaleHeight - 50 rn .CurrentX = 0rn .CurrentY = 0rnEnd WithrnWith Printerrn .FontSize = 20rn .CurrentX = (usewidth - .TextWidth("成品標籤")) / 2rnEnd Withrn........rn........rn每次一運行...在第一個with printer下的第一個屬性就出錯了rn提示"執行階段錯誤'-2147417848(80010108)rn papersize方法('_printer)失敗rn就是with printer下面的方法都用不了...rn請問是什么原因呀.....rn郁悶几天了...
創建復制數據庫失敗.
我想創建一個復制數據庫時出現如下錯誤﹐請問這是什么原因.它要我查看 instdist.out文件﹐其內容如下Login failed for user 'NT AUTHORITY\SYSTEM'rn其對話框上出現error 14113,到在線幫助中查看為rn 14113 Could not execute '%s'. Check '%s' in the install directory rnrnrnrn請問是什么原因﹐怎么解決呢﹖rn
用VB.net發送Email失敗
我想用VB.net發送Email,一併cc副本給使用者所留的email,但是收不到郵件。請問是怎麼回事?下面是代碼︰rnPublic Function SenExportFile(ByVal LSTR_EmailAddress As String, ByVal LSTR_AttachPath As String, ByVal LSTR_ExportContent As String, ByVal LSTR_Subject As String, ByVal LSTR_From As String, ByVal LSTR_Cc As String) As String Implements IBU_TEPS.SenExportFilern '*****必要宣告*****rn Dim LSTR_ClassName As Stringrn Dim LSTR_MethodName As Stringrn Dim LSTR_MethodID As String = "07"rnrn Dim LSTR_LogFile As Stringrn '*****額外宣告*****rn Dim SMail As System.Web.Mail.SmtpMailrn Dim message As New Web.Mail.MailMessagern Dim attachFile As MailAttachmentrn Dim attachFile1 As MailAttachmentrn Dim attachFile2 As MailAttachmentrnrn Dim LSTR_XlsData As Stringrn Dim LSTR_FileName As Stringrn Dim LOBJ_Component As Objectrn Dim GCST_TEPSReportPath As Stringrnrn GCST_TEPSReportPath = ITG.Common.GetProfileString(ITG.Common.GCST_EnvParameter, "TEPSReportPath", "", ITG.Common.GCST_IniFileName)rn Tryrn LSTR_ClassName = "ITG.BU_TEPS"rn LSTR_MethodName = "SenExportFile"rn LSTR_LogFile = LSTR_ClassName & "_" & LSTR_MethodName & ".log"rn ITG.Common.LogFile(LSTR_LogFile)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_EmailAddress", LSTR_EmailAddress)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_AttachPath", LSTR_AttachPath)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_ExportContent", LSTR_ExportContent)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_EmailAddress", LSTR_EmailAddress)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_From", LSTR_From)rn ITG.Common.LogFile(LSTR_LogFile, "LSTR_Cc", LSTR_Cc)rnrn message.To = CStr(LSTR_EmailAddress)rn message.From = CStr(LSTR_From)rn If CStr(LSTR_Cc) <> "" Thenrn message.Cc = CStr(LSTR_Cc)rn End Ifrn message.Body = LSTR_ExportContentrn message.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8")rn message.BodyFormat = Web.Mail.MailFormat.Htmlrn message.Priority = Web.Mail.MailPriority.Highrn message.Subject = LSTR_Subjectrnrn Call SMail.Send(message)rnrn SenExportFile = GCST_CorrectRC + GCST_TEPSReportPath + LSTR_AttachPathrn ITG.Common.LogFile(LSTR_LogFile, SenExportFile)rn ContextUtil.SetComplete()rn Catch Exception As System.Exceptionrn SenExportFile = GCST_NotCorrectRC + Exception.Messagern ITG.Common.LogFile(LSTR_LogFile, SenExportFile)rn If Not LOBJ_Component Is Nothing Thenrn LOBJ_Component = Nothingrn End Ifrn ContextUtil.SetAbort()rn Throw Exceptionrn Finallyrn If Not LOBJ_Component Is Nothing Thenrn LOBJ_Component = Nothingrn End Ifrn End Tryrn End Functionrn急等。請各位大蝦幫幫忙!謝謝了!