Ⅰ 如何在excel中自動寫入資料庫
首先,需要在excel中添加載入項--數據分析庫,然後就可以進行數據自動生成了,以專業的術語叫做「隨機數發生器」。依次點擊:excel選項-載入項-轉到,進行分析工具庫的添加工作。
分析工具庫添加完成之後,在excel的「數據」選項卡上,最右側會多出一個「分析」的菜單欄,點擊「數據分析」。
選擇「數據分析」下的「隨機數發生器」。
彈出的界面上,為隨機數發生器的參數設置界面。其中,變數個數=生成數據列數、隨機數個數=生成數據行數,比如,設置:變數個數=5、隨機數個數=10,那麼,就會生成一個5列、10行的數據。
接下來,選擇隨機數據的分布類型,以「正態分布」為例,設定:平均值=50、標准差=5。
選定數據的輸出位置,可以選定區域、新建工作表、新建工作簿,本例中以選定區域為例來說情況,如下圖,選擇將數據輸出到:A1:E10區域中。
數據輸出成功,如下圖所示。
Ⅱ 如何將vb中輸入的數據自動儲存在資料庫中
首先要確定一下您所謂的自動是什麼意思,是在文本框中輸完就保存呢還是在您全部輸入一系列相關內容後按某個鍵後保存,
如是第一種情況,
那麼您保存的代碼應該寫在文本框的事件中,如您在文本框中輸入一個回車表示您輸入完畢保存數據
Private
Sub
Text1_KeyPress(KeyAscii
As
Integer)
If
KeyAscii
=
13
Then
'輸入了回車
rs.addnew
rs
Ⅲ 如何:將數據從對象保存到資料庫
有關更多信息,請參見 TableAdapter 概述。若要保存對象集合中的數據,請循環通過對象集合(例如,for-next 循環),然後使用 TableAdapter 的 DBDirect 方法之一將每個對象的值發送到資料庫中。默認情況下,DBDirect 方法在 TableAdapter 上創建,能夠直接對資料庫執行操作。這些方法可以直接調用,它們不要求 DataSet 或DataTable 對象來協調更改即可將更新發送到資料庫。注意配置TableAdapter 時,主查詢必須提供足夠的信息,才能創建 DBDirect 方法。例如,如果將 TableAdapter 配置為從未定義主鍵列的表中查詢數據,它將不會生成 DBDirect 方法。 TableAdapter DBDirect 方法 說明TableAdapter.Insert向資料庫中添加新記錄,此方法允許將值作為方法參數傳入各個列。TableAdapter.Update更新資料庫中的現有記錄。Update 方法將原始列值和新列值用作方法參數。原始值用於定位原始記錄,新值用於更新該記錄。通過將 DataSet、DataTable、DataRow、或 DataRow 數組用作方法參數,TableAdapter.Update 方法還可用於將數據集中的更改協調回資料庫。TableAdapter.Delete在基於作為方法參數傳入的原始列值的資料庫中,刪除其現有記錄。將對象中的新記錄保存到資料庫中通過將值傳遞給 TableAdapter.Insert 方法可創建這些記錄。下面的示例通過將 currentCustomer 對象中的值傳遞給 TableAdapter.Insert 方法,在 Customers 表中創建一項新的客戶記錄。 Visual Basic PrivateSub AddNewCustomer(ByVal currentCustomer As Customer) CustomersTableAdapter.Insert( _ currentCustomer.CustomerID, _ currentCustomer.CompanyName, _ currentCustomer.ContactName, _ currentCustomer.ContactTitle, _ currentCustomer.Address, _ currentCustomer.City, _ currentCustomer.Region, _ currentCustomer.PostalCode, _ currentCustomer.Country, _ currentCustomer.Phone, _ currentCustomer.Fax) EndSub C# privatevoid AddNewCustomers(Customer currentCustomer) { customersTableAdapter.Insert( currentCustomer.CustomerID, currentCustomer.CompanyName, currentCustomer.ContactName, currentCustomer.ContactTitle, currentCustomer.Address, currentCustomer.City, currentCustomer.Region, currentCustomer.PostalCode, currentCustomer.Country, currentCustomer.Phone, currentCustomer.Fax); } J# privatevoid AddNewCustomers(Customer currentCustomer) { .Insert( currentCustomer.get_CustomerID(), currentCustomer.get_CompanyName(), currentCustomer.get_ContactName(), currentCustomer.get_ContactTitle(), currentCustomer.get_Address(), currentCustomer.get_City(), currentCustomer.get_Region(), currentCustomer.get_PostalCode(), currentCustomer.get_Country(), currentCustomer.get_Phone(), currentCustomer.get_Fax()); }將對象中的現有記錄更新到資料庫修改記錄:調用 TableAdapter.Update 方法並傳入新值可更新記錄,而傳入原始值可定位記錄。注意對象需要保留其原始值,才能將它們傳遞給 Update 方法。此示例使用前綴為 orig 的屬性存儲原始值。下面的示例通過將 Customer 對象中的新值和原始值傳遞給 TableAdapter.Update 方法,更新 Customers 表中的現有記錄。 Visual Basic PrivateSub UpdateCustomer(ByVal cust As Customer) CustomersTableAdapter.Update( _ cust.CustomerID, _ cust.CompanyName, _ cust.ContactName, _ cust.ContactTitle, _ cust.Address, _ cust.City, _ cust.Region, _ cust.PostalCode, _ cust.Country, _ cust.Phone, _ cust.Fax, _ cust.origCustomerID, _ cust.origCompanyName, _ cust.origContactName, _ cust.origContactTitle, _ cust.origAddress, _ cust.origCity, _ cust.origRegion, _ cust.origPostalCode, _ cust.origCountry, _ cust.origPhone, _ cust.origFax) EndSub C# privatevoid UpdateCustomer(Customer cust) { customersTableAdapter.Update( cust.CustomerID, cust.CompanyName, cust.ContactName, cust.ContactTitle, cust.Address, cust.City, cust.Region, cust.PostalCode, cust.Country, cust.Phone, cust.Fax, cust.origCustomerID, cust.origCompanyName, cust.origContactName, cust.origContactTitle, cust.origAddress, cust.origCity, cust.origRegion, cust.origPostalCode, cust.origCountry, cust.origPhone, cust.origFax); } J# privatevoid UpdateCustomer(Customer cust) { .Update( cust.get_CustomerID(), cust.get_CompanyName(), cust.get_ContactName(), cust.get_ContactTitle(), cust.get_Address(), cust.get_City(), cust.get_Region(), cust.get_PostalCode(), cust.get_Country(), cust.get_Phone(), cust.get_Fax(), cust.get_origCustomerID(), cust.get_origCompanyName(), cust.get_origContactName(), cust.get_origContactTitle(), cust.get_origAddress(), cust.get_origCity(), cust.get_origRegion(), cust.get_origPostalCode(), cust.get_origCountry(), cust.get_origPhone(), cust.get_origFax()); }刪除資料庫中的現有記錄通過調用 TableAdapter.Delete 方法並傳入原始值定位記錄,可刪除記錄。注意對象需要保留其原始值,才能將它們傳遞給 Delete 方法。 Visual Basic PrivateSub DeleteCustomer(ByVal cust As Customer) CustomersTableAdapter.Delete( _ cust.origCustomerID, _ cust.origCompanyName, _ cust.origContactName, _ cust.origContactTitle, _ cust.origAddress, _ cust.origCity, _ cust.origRegion, _ cust.origPostalCode, _ cust.origCountry, _ cust.origPhone, _ cust.origFax) EndSub C# privatevoid DeleteCustomer(Customer cust) { customersTableAdapter.Delete( cust.origCustomerID, cust.origCompanyName, cust.origContactName, cust.origContactTitle, cust.origAddress, cust.origCity, cust.origRegion, cust.origPostalCode, cust.origCountry, cust.origPhone, cust.origFax); } J# privatevoid DeleteCustomer(Customer cust) { .Delete( cust.get_origCustomerID(), cust.get_origCompanyName(), cust.get_origContactName(), cust.get_origContactTitle(), cust.get_origAddress(), cust.get_origCity(), cust.get_origRegion(), cust.get_origPostalCode(), cust.get_origCountry(), cust.get_origPhone(), cust.get_origFax()); }安全您必須具有相應的許可權,才能對資料庫中的表執行選定的 INSERT、UPDATE 或 DELETE。
Ⅳ 怎樣把文本文檔里存儲的數據存到資料庫
將帶有格式的文本保存到資料庫中的方法/步驟:
1、在jsp中,頁面的帶有格式的文本內容外面用一個大的標簽,給定表簽名。
2、頁面做提交的時候用上面的表簽名點innerHTML的方式來獲取頁面帶有標簽和樣式的內容。
3、將上面取得的內容作為一個字元串保存到資料庫即可,下次把資料庫里的內容直接輸出到頁面就可以了。
對於要輸出到word里保存樣式的方法也是類似的,只是需要去看一下word解析文本的方式與jsp有何區別,在輸出到word的時候做一下變換即可。
Ⅳ 把用戶操作記錄保存到mysql資料庫怎麼實現
修改my.cnf,在[mysqld]段加入
log-bin
重啟mysql服務後,你的操作會在資料庫的目錄中生成一些mysqld.bin.000001文件,這些就是操作日誌。你的對數據的操作,如創建表格,插入,刪除等,都會被記錄進去。
這個功能還被用於雙機資料庫熱備份。
Ⅵ 怎麼講歷史記錄保存到資料庫。啊。。
保存就是向資料庫寫入數據啊,就是調用insert語句啊,具體架構你自己設計
Ⅶ VB中將查詢記錄自動保存到資料庫中
假設是本地資料庫,簡單的方法是採用Data控制項:
Data1.DatabaseName = "資料庫文件標識符" '連接資料庫文件,帶磁碟路徑
Data1.RecordSource = "數據表名"'連接數據表
Data1.Refresh'刷新記錄集
Data1.Recordset.AddNew '在記錄集末尾添加一條空記錄
Data1.Recordset.Fields("欄位名1") = XXX1'將欄位值添加(替換)到空記錄
Data1.Recordset.Fields("欄位名1") = XXX2'將欄位值添加(替換)到空記錄
Data1.Recordset.Update '必要的更新操作
其中:XXX1和XXX2可以是與相關欄位的數據類型一致的任意表達式.
Ⅷ 如何記錄用戶的瀏覽記錄到資料庫
寫一個過濾器,過濾所有的路徑。在這個過濾器中你需要獲取到用戶的IP,UID,使用request.getRequestURI()獲取到用戶請求的路徑,保存到資料庫中就行了。在後台做一個展現頁面,根據你的分析統計演算法進行分析。
Ⅸ 如何將Excel表單數據自動導入導出Access資料庫
方法/步驟
Excel表單數據與Access之間的轉換主要通過宏來實現。首先打開資料庫,在工具欄中查找到「創建-宏」點擊宏,出現圖2的界面。
創建Excel表單數據導入宏:點擊工具欄中的「設計-顯示所有操作」,點擊宏的選擇菜單(下圖2),選擇「TransferSpreadsheet」;
數據導入設置(下圖3):
1、遷移類型選擇「導入」
2、電子表格類型選擇「Microsoft Excel 97 - Excel 2003 Workbook」
3、表名稱:如果你要輸入到Access已有表中,就輸入現有表的名稱,如果要新建表,就輸入所要新建表的名稱,導入後會自動生成新表。
4、文件名稱:也就是你所需要導入的Excel表的完整路徑和表單名。
5、帶有欄位名稱選擇」是「。
6、范圍可以不選擇。
設置完成後,點擊左上角的保存圖標,輸入自己定義的宏的名稱後」確認「,Excel導入的宏創建完成(下圖2)。如果運行,就用滑鼠左鍵雙擊,就會將數據導入所需要的表中或者自動生成新表(下圖3)。
創建Excel表單數據導出宏:步驟基本同於第二步,選擇「TransferSpreadsheet」,只是在導出設置時有一點區別。
數據導入設置(下圖):
1、遷移類型選擇「導出」
2、電子表格類型選擇「Microsoft Excel 97 - Excel 2003 Workbook」
3、表名稱:是指Access資料庫中需要導出的表的名稱。
4、文件名稱:是指從資料庫中導出到目標Excel表的完整路徑和表名。
5、帶有欄位名稱選擇」是「。
6、范圍可以不選擇。
保存和運行方式如第三步。
創建操作面板:工具欄中」資料庫工具-切換面板管理器「。
面板管理器設置:
1、選擇」主切換面板「點擊編輯(下圖1);
2、點擊」新建「出現(圖3)的界面」編輯切換面板項目「;
3、編輯切換面板項目的設置:
1、文本:就是你所需要創建的項目名稱,如將名字設為「生產報表導 入」;
2、命令:資料庫內表單的方式,選擇「運行宏」;
3、宏:選擇需要運行的宏,如上已經創建好的宏「生產報表導入」;
4、按」確定「完成設置。
5、按以上步驟完成」生產報表導出「的面板設置。
6、關閉資料庫面板設置:選擇」新建「-文本命名為」關閉資料庫「-命令選擇「退出應用程序」-「確定」(如下圖4)。
4、選擇「關閉」鍵,面板設置完成。
滑鼠雙擊左鍵窗體中的」切換面板「出現如圖界面,只要點擊圖中的紅色圈中的按鍵,就會自動完成數據的導入、導出和資料庫的關閉。
希望本篇對你有所幫助。