vb中,如何根据text中的值作为字段,在SQL数据库中创建一张新表?程序运行时,我在text1,text2,text3,text4,text5中分别输入值,其中text1中的值作为表名,text2-5中是数值作为表的字段名,我用的是SQL2000,请教大家,我该如何实现?先在此谢过了

解决方案 »

  1.   

    使用Create Table
    看看这个
      

  2.   

    我知道用那个啊,但是一直不成功,我的代码
    Dim cn As New adodb.Connection                                     '定义数据库的连接
    Dim Rs As New adodb.Recordset
    Dim sqlstr As String
    cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CSL;Data Source=MICROSOF-1557BB"
    Rs.CursorLocation = adUseClient
    sqlstr = "create TABLE ‘“ & Text1.text &”’(日期 datetime,'" & Text2.Text & "' real,'" & Text3.Text & "' real,'" & Text4.Text & "' real,'" & Text5.Text & "' real)"
    Rs.Open sqlstr, cn
    一直显示有语法错误
      

  3.   

    麻烦大家帮我看,错在哪?我是用VB两SQL2000哦
      

  4.   

    sqlstr = "create TABLE " & Text1.text & "(日期 datetime," & Text2.Text & " real," & Text3.Text & " real," & Text4.Text & " real," & Text5.Text & " real)"