资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net数据库语法 vbnet access数据库

vb.net update语法

其他的没法看,不过下面这句是肯定有问题的,应该连编译都过不了:

目前创新互联已为上千的企业提供了网站建设、域名、虚拟空间、网站托管、企业网站设计、谢通门网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

Dim querystring As String = "update 班级信息表 set 班级名称="TextBox1.Text",班级编号="TextBox2.Text""

改称这样试试:

Dim querystring As String

querystring = "update 班级信息表 set 班级名称=" chr(39) TextBox1.Text chr(39) ", 班级编号=" chr(39) TextBox2.Text chr(39)

vb.net查询语法

顺序应该是先Connection的Open

con.ConnectionString = constr

con.Open()

dc = New OleDbDataAdapter(sql, constr)

另外你的SQL语句好像有点问题,表名不加单引号

高分求.net里vb语法操作数据库基本语句

Dim Cnn As New Data.OleDb.OleDbConnection

Dim DbAdapter As New Data.OleDb.OleDbDataAdapter

Dim Cmd As New Data.OleDb.OleDbCommand

Dim dsAll As New Data.DataSet

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\webapp\test\web.mdb"

Cmd.Connection = Cnn

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

'插入

Cmd.CommandText = "insert into main (about) values ('" + TextBox1.Text + "')"

UpdateTable()

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

'修改

Dim ids As Integer

ids = 1

Cmd.CommandText = "update main set about='" + TextBox1.Text + "' where id=" + ids.ToString()

UpdateTable()

End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

'删除

Dim ids As Integer

ids = 1

Cmd.CommandText = "delete from main where id=" + ids.ToString()

UpdateTable()

End Sub

Public Sub UpdateTable()

Dim Trans As Data.OleDb.OleDbTransaction

Try

Cnn.Open()

Trans = Cnn.BeginTransaction()

Try

Cmd.Transaction = Trans

Cmd.ExecuteNonQuery()

Trans.Commit()

Catch

Trans.Rollback()

Finally

If (Cnn.State = System.Data.ConnectionState.Open) Then

Cnn.Close()

End If

End Try

Catch

'error message

End Try

End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click

'显示

Cmd.CommandText = "select id, about from main"

DbAdapter.SelectCommand = Cmd

DbAdapter.Fill(dsAll, "table1")

If (dsAll.Tables("table1").Rows.Count 0) Then

TextBox1.Text = dsAll.Tables("table1").Rows(0)("about")

Else

TextBox1.Text = ""

End If

End Sub


网页标题:vb.net数据库语法 vbnet access数据库
文章分享:http://cdkjz.cn/article/doihcod.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220