水平有限,给你一个代码。不过好像有些复杂,但是能够在已有的数据库中动态创建表。数据库是Access的。
Dim cat As New ADOXCatalog '动态创建盘点表用
Dim pstr As String
Dim tb As New Table
pstr = "Provider=MicrosoftJetOLEDB40;Data Source=" & AppPath & "\Datamdb" '不能把这里的40改为351
catActiveConnection = pstr
tbName = "店库存盘点明细" '表的名称
tbColumnsAppend "产品编号", adVarWChar, 50 '以下是表的字段
tbColumnsAppend "类别", adVarWChar, 50
tbColumnsAppend "年份", adVarWChar, 50
tbColumnsAppend "季节", adVarWChar, 50
tbColumnsAppend "入库日期", adDate
tbColumnsAppend "入库件数", adInteger
tbColumnsAppend "客退件数", adInteger
tbColumnsAppend "在途件数", adInteger
tbColumnsAppend "FROM", adVarWChar, 50
tbColumnsAppend "销售/出库时间", adDate
tbColumnsAppend "销售件数", adInteger
tbColumnsAppend "调出件数", adInteger
tbColumnsAppend "次品退仓件数", adInteger
tbColumnsAppend "TO", adVarWChar, 50
tbColumnsAppend "节余数量", adInteger
tbColumnsAppend "外借", adInteger
tbColumnsAppend "维修", adInteger
tbColumnsAppend "备注", adVarWChar, 50
'==============以下设置字段允许为空==============
tbColumns("入库日期")Attributes = adColNullable
tbColumns("入库件数")Attributes = adColNullable
tbColumns("客退件数")Attributes = adColNullable
tbColumns("在途件数")Attributes = adColNullable
tbColumns("FROM")Attributes = adColNullable
tbColumns("销售/出库时间")Attributes = adColNullable
tbColumns("销售件数")Attributes = adColNullable
tbColumns("调出件数")Attributes = adColNullable
tbColumns("次品退仓件数")Attributes = adColNullable
tbColumns("TO")Attributes = adColNullable
tbColumns("节余数量")Attributes = adColNullable
tbColumns("外借")Attributes = adColNullable
tbColumns("维修")Attributes = adColNullable
tbColumns("备注")Attributes = adColNullable
catTablesAppend tb '建立数据表
MsgBox "盘点明细表创建完成!", vbInformation, "创建表"
Set tb = Nothing
Set cat = Nothing
public void CreateMDB()
{
//为了方便测试,数据库名字采用比较随机的名字,以防止添加不成功时还需要重新启动IIS来删除数据库。
string time = DateTimeNowYearToString();
if (DateTimeNowMonth < 10)//判断当前月是否小于10
{
time += "0" + DateTimeNowMonth;
}
else
{
time += DateTimeNowMonth;
}
time += DateTimeNowDay;
string apppath = SystemWeb>
以上就是关于vb中新建数据库表的问题全部的内容,包括:vb中新建数据库表的问题、asp.net中怎么创建MDB数据库和表,以及将数、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)