标题:asp.net中VB的语法有错
只看楼主
guaishi
Rank: 1
等 级:新手上路
帖 子:156
专家分:0
注 册:2007-6-15
得分:0 
这个是可以正常运行,放到那个分区也不可以运行了,这种事如何解释。
Partial Class show
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
        'Response.Write(i)
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conn = New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath("mdb.mdb"))
        Dim sql As String = "select * from dcontd"
        Dim comm = New Data.OleDb.OleDbCommand(sql, conn)
        conn.open()
        Dim ds As Data.OleDb.OleDbDataReader
        ds = comm.ExecuteReader()

        While (ds.Read())
            Response.Write(Convert.ToSingle(ds("id")))
            Response.Write("<br>")
            Response.Write(Convert.ToString(ds("dotype")))
            Response.Write("<br>")
            Response.Write(Convert.ToString(ds("dtext")))
            Response.Write("<br>" & "新记录:")
            Response.Write(Convert.ToString(ds("daddress")))
            Response.Write("<br>")
        End While
        ds.Close()
        conn.close()

        Dim sqll As String = "insert into dcontd(daddress,dtext)values('" + user.Text + "','" + pwd.Text + "')"
        Dim con = New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath("mdb.mdb"))
        con.open()
        Dim cc = New Data.OleDb.OleDbCommand(sqll, con)
        cc.executenonquery()



    End Sub
End Class

网络改变了我,编程改变了我的生活
2008-05-17 09:30
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
得分:0 
因为user是sql的保留字,你加上[]就可以了……
2008-05-17 11:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-214560-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.291049 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved