大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
你这是vb.net的代码,vb中不允许那么写:
创新互联公司专注于罗江企业网站建设,响应式网站设计,购物商城网站建设。罗江网站建设公司,为罗江等地区提供建站服务。全流程按需制作网站,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务
Dim
strdx()
As
String
=
{"0",
"0",
"0"}
'定义个数组,从后面的值能看的出最大下标是2,也就是strdx(0),strdx(1)和strdx(2),3个的默认值都为0
Dim
calcount1
As
String
=
"0"
'定义个字符串变量
Dim
calcount2
As
String
=
"0"
Dim
strvalue
As
Boolean
=
False
'定义strvalue为bool值,改类型变量只有true和false
2种值
If
strdx(0)
=
"0"
Then
TextBox1.Text
=
strdx(0)
"."
这是字符串连接符号,和"+"的区别是,他把左右2边的内容直接连接的,而"+"可能会编程运算符,例如
2
3
=
"23"
而
2
+
3
=
5
ElseIf
strvalue
=
False
Then
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
"."
strvalue
=
True
Else
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
Select
Case
calcount1
'
这里开始是分支语句
Case
"+"
TextBox1.Text
=
Str(Val(strdx(1))
+
Val(strdx(0)))
#If...Then...#Else 指令
根据条件编译选定的 Visual Basic 代码块,需要有#Const 配对,一般要先用#Const 定义条件编译器常量
'以下是例子
Module Module1
#Const i = 60
Sub Main()
#If i 30 Then
Console.WriteLine("???") '如果用#Const定义了i,该句语句才会执行,假如用的是private i as integer=60定义,该语句不会被执行
#End If
End Sub
End Module
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
顺序应该是先Connection的Open
con.ConnectionString = constr
con.Open()
dc = New OleDbDataAdapter(sql, constr)
另外你的SQL语句好像有点问题,表名不加单引号
不一样的,主要的关键字差不多,语法有一些有变化
vb.net与vb语法的一个很大不同——oop设计
例如
sMyString = Mid(sMyString,3,4)
现在,它可以被替换为:
sMyString = sMyString.substring(3,4)
前者是二维矩形数组,即传统的二维数组,后者是交错数组.
有时,应用程序中的数据结构是两维的但不是矩形。例如,一个月份的数组,其每个元素又是天数的数组。由于不同的月份有不同的天数,元素不能构成一个矩形的两维数组。在这种情况下,可以使用交错数组而不是多维数组。