1. 首页>动态要闻 > 信息

怎么把数据传入数据库

作者:马楠
2020-04-22
信息

1.数据是如何存入数据库中的

我是玩JAVA的所以我用JAVA的例子给你说个看把,直接用中文说比较容易理解.

首先:

1.要下载一个对应你数据库的驱动包,如 sqlserver2008.java; 灵魂伴侣手写.

2.然后写个连接数据库的类.如JDBC.(连接数据库方法有很多种, 按照技术来分,首先学会JDBC连接数据库,然后连接池,然后框架技术Hibernate.) 灵魂伴侣手写.

3.每个数据库的表对应一张实体类,实体类是干什么用的? 1.用它可以OOP的思想的去操作数据库.

(增删改查), 表中的字段就封装成实体类里面的一个属性. 如表里是name char(10),那么实体类对应的是private String name;

4.用户登录Web输入帐号,密码, 通过各种方法可以获取到用户输入的数据.

5.封装到实体类.

6.用JDBC提供对数据库操作的API.

7.调用方法.写入数据库.

end

最后我想说刚学数据库一步步来,我也是学java中把mysql和SQL server和Oracle学会的.

建议你找门语言辅助的学数据库好点.如.Net 和java.

我现在是一个Oracle的数据库管理员和个javaWeb企业开发人员.

希望能帮助你.

2.如何将excel中的数据传到数据库中

1、打开企业管理器,打开要导入数据的数据库,在表上按右键,所有任务-->;导入数据,弹出DTS导入/导出向导,按 下一步 ,

2、选择数据源 Microsoft Excel 97-2000,文件名 选择要导入的xls文件,按 下一步 ,

3、选择目的 用于SQL Server 的Microsoft OLE DB提供程序,服务器选择本地(如果是本地数据库的话,如 VVV),使用SQL Server身份验证,用户名sa,密码为空,数据库选择要导入数据的数据库(如 client),按 下一步 ,

4、选择 用一条查询指定要传输的数据,按 下一步 ,

5、按 查询生成器,在源表列表中,有要导入的xls文件的列,将各列加入到右边的 选中的列 列表中,这一步一定要注意,加入列的顺序一定要与数据库中字段定义的顺序相同,否则将会出错,按 下一步 ,

6、选择要对数据进行排列的顺序,在这一步中选择的列就是在查询语

3.如何将excel表数据导入MySql数据库

一般有两种方式来处理

1、使用js来读取本地excel文件,读出一行后,使用ajax传入后台进行持久化操作(存入数据库),这种方式仅限于windows和ie,要使用

var oXL = new ActiveXObject("Excel.application");

var oWB = oXL.Workbooks.open(filePath);

oWB.worksheets(1).select();

var oSheet = oWB.ActiveSheet;

2、使用poi插件来处理,前台使用<input type="file" value="">;来加载本地excel文件,提交到后台后,使用流保存到服务器,在使用poi处理,保存进入数据库

从安全性和规范性、通用性考虑,第二种方法更为合适

4.谁知道做好了表单后怎么样把表单上的数据传入数据库

以下是上传页面的内容,我把它封装到一个函数里了,希望能对你有所帮助:

<!-- #include file="conn.asp"-->; '连接到你的数据库上。

<%

sub upload

dim sql,rs

sql="insert [表名] value('"&表单变量1&"''"&表单变量2&"''"&表单变量3&"''"&表单变量4&"')"

conn.execute(sql)

response.Write("添加成功!")

end sub

%>

5.如何:将数据从对象保存到数据库

有关更多信息,请参见 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) { northwindDataSetCustomersTableAdapter.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) { northwindDataSetCustomersTableAdapter.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(), 。

6.网站数据库,怎么导入

操作方法如下:

第一步、登录phpmyadmin数据库管理工具。

第二步、登录phpmyadmin工具,需要您输入mysql数据库用户名和数据库密码。(这个登录信息,在新建mysql数据库的时候可以获得)

第四步、选择数据库,点击“导入”。

怎么把数据传入数据库

推荐阅读
  • 日照好玩的地方和吃海鲜应该去哪听说日

    日照好玩的地方:万平口:"旅游来日照,必到万平口",已成为各地游客的共识。刘家湾赶海园:以赶海系列活动为主,集旅游、休闲、度假、民俗、健身于一体的综合旅游园。竹洞天:位于山东省日照市城区西端的将帅沟毛竹…

    信息 2024-09-20
  • 什么是铸造

    铸造是指将室温中为液态,但不久后将要固态化的物质倒入特定形状的铸模待其凝固成形的加工方式。 被铸物质多半原为固态但加热至液态的金属(例:铜、铁、铝、锡、铅等),而铸模的材料可以是沙、金属甚至陶瓷。 因应…

    信息 2024-09-20
  • 变形金刚中博派和狂派各有哪些人物

    博派:擎天柱,铁皮,大黄蜂,爵士,棘齿。狂派:威震天,红蜘蛛,眩晕,吵闹,萨克,碎骨魔,路障,迷乱。…

    信息 2024-09-20
  • 一平方毫米的铜线能过多少安的电流

    1平方毫米的铜线在不同电流下通过的安培数不同。最大是18A:(1)60A以下,选1平方毫米的铜线安全载流量是6A;(2)60~100A,选1平方毫米的铜线,安全载流量是5A;(3)100A以上,选1平方毫米的铜线,安全载流量是2.5A 。…

    信息 2024-09-20
  • 中华人民共和国城乡规划法第四十条有规

    自2008年1月1日起施行的《中华人民共和国城乡规划法》第四十条:在城市、镇规划区内进行建筑物、构筑物、道路、管线和其他工程建设的,建设单位或者个人应当向城市、县人民政府城乡规划主管部门或者省、自治区、直辖…

    信息 2024-09-20