如何在VB.NET中立即创建表并将其添加到DataSet中 [英] How to Create a Table and Add it into DataSet immediately in VB.NET

查看:87
本文介绍了如何在VB.NET中立即创建表并将其添加到DataSet中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,它在我的数据库中添加了表,但没有将它添加到DataSet中。

我只想从我创建的表中获取数据。

由于创建的表不在DataSet中,我无法从中获取数据。



这里是我的代码。



I Had this Code, that adds table in my database, but didn't add it into DataSet.
Simply i want to fetch the data from the table i created.
As the created table is not in DataSet, i can't fetch data from it.

Here the code i have.

con.Open()
Dim dbSchema As DataTable = con.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, TextBox1.Text, "TABLE"})
con.Close()


If dbSchema.Rows.Count > 0 Then
      MsgBox("Table Exist")
Else

Dim cmd As New OleDb.OleDbCommand("CREATE TABLE [" + TextBox1.Text + "] ([Field1] TEXT(10), [Field2] TEXT(10))", con)
con.Open()
cmd.ExecuteNonQuery()
MessageBox.Show("Table Created Successfully")
con.Close()
End If





这是一个在数据库中添加新表的工作代码,但不在DataSet中。



This is a working code to add new table in database, but not in DataSet.

推荐答案

什么你说的没有任何意义。您提供的代码仅创建一个包含数据库中几个字段的表。除了用数据填充它之外,没有别的办法可以阻止你查询数据库并获取数据。



没有 DataSet这里的概念。
What you're saying does not make any sense. The code you presented only creates a table with a few fields in a database. There is nothing else you have to do, other than populating it with data, that will prevent you from querying the database and getting the data back.

There is no "DataSet" concept here.


这篇关于如何在VB.NET中立即创建表并将其添加到DataSet中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆