关于vb.net增删的信息-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

关于vb.net增删的信息

VB.net求一个简单的增删改页面。

VS+access数据库的,MSSQL数据库的话你改下,反正就2种链接方式,书上都有。

成都创新互联,为您提供网站建设网站制作、网站营销推广、网站开发设计,对服务成都建筑动画等多个行业拥有丰富的网站建设及推广经验。成都创新互联网站建设公司成立于2013年,提供专业网站制作报价服务,我们深知市场的竞争激烈,认真对待每位客户,为客户提供赏心悦目的作品。 与客户共同发展进步,是我们永远的责任!

下面是代码和解释,另外我会把文件发到你邮箱里的,你把文件复制到自己的站点文件夹里面运行就可以看到效果了。

Imports System.Data.OleDb

Imports System.Data

Partial Class baidu

Inherits System.Web.UI.Page

'下面是添加记录

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

'定义“连接数据库”和“执行SQL”变量

Dim myConnection As OleDbConnection

Dim myCommand As OleDbCommand

Dim dbname As String

dbname = Server.MapPath("baidu.mdb")

myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" dbname)

myConnection.Open()

'INSERT INTO "表格名" ("栏位1", "栏位2", ...) VALUES ("值1", "值2", ...)

'这里可以加上 昵称 是否已经存在的判断语句,就是 SELECT "栏位名" FROM "表格名" WHERE "条件"

myCommand = New OleDbCommand("Insert INTO a1(昵称) Values('" TextBox1.Text "')", myConnection)

myCommand.ExecuteNonQuery()

Response.AddHeader("Refresh", "0")

'关闭连接()

myConnection.Close()

'释放资源

myCommand.Dispose()

End Sub

'下面是删除记录

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

'定义“连接数据库”和“执行SQL”变量

Dim myConnection As OleDbConnection

Dim myCommand As OleDbCommand

Dim dbname As String

dbname = Server.MapPath("baidu.mdb")

myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" dbname)

myConnection.Open()

'DELETE FROM "表格名" WHERE {条件}

myCommand = New OleDbCommand("DELETE FROM a1 WHERE 昵称 = '" TextBox1.Text "'", myConnection)

myCommand.ExecuteNonQuery()

Response.AddHeader("Refresh", "0")

'关闭连接()

myConnection.Close()

'释放资源

myCommand.Dispose()

End Sub

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

'定义“连接数据库”和“执行SQL”变量

Dim myConnection As OleDbConnection

Dim myCommand As OleDbCommand

Dim dbname As String

dbname = Server.MapPath("baidu.mdb")

myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" dbname)

myConnection.Open()

myCommand = New OleDbCommand("select * FROM a1", myConnection)

GridView1.DataSource = myCommand.ExecuteReader()

GridView1.DataBind()

'关闭连接()

myConnection.Close()

'释放资源

myCommand.Dispose()

End Sub

End Class

邮件已经发生,请查收。记得给分哈

求一个vb.net链接mysql数据库的增删改查程序,求速度。。。

首先你本地要安装MySQL Connector Net

工程引用mysql.data

连接数据库:

 Imports MySql.Data

Imports MySql.Data.MySqlClient

‘连接字符串dbServerName 是ip,下面的英文应该懂得吧。

dim sA as string

sA = "server=" Me.dbServerName "; port=3306; database=" Me.dbDataBaseName _

                  "; user id=" Me.dbUserName "; password=" Me.dbPassWord "; "

dim mvardbConnectionMysql As MySqlConnection

          With mvardbConnectionMysql

                .ConnectionString = sA

              .Open()

          End With

4. 读取数据

dim xx As MySqlDataReader

Dim oC As MySqlCommand = New MySqlCommand(sSql, Me.mvardbConnectionMysql)

oC.CommandType = CommandType.Text

xx= oC.ExecuteReader()

if xx.HasRows

do while xx.read()   ’一次读取一行

msgbox xx.item(2)   '取出当前行的第三个字段的值显示。

loop

end if

5. 写入数据

  Dim oT As MySqlTransaction = Me.mvardbConnectionMysql.BeginTransaction()

  Try

      Dim oC As MySqlCommand

   '下面的commandtext是执行的更新语句,例如Insert into 语句。

      oC = New MySqlCommand(CommandText, Me.mvardbConnectionMysql, oT)

      oC.CommandType = CommandType.Text

      oC.ExecuteNonQuery()

      oT.Commit()

      oC = Nothing

      oT = Nothing

  Catch oe As Exception

      oT.Rollback()

  End Try

求一个VB.net 增删改查实例 ,哪位大神有空帮我写一下或者有现成的给我一个,,我比较菜又比较急,在线等

Imports System.Data.OleDb

'Imports System.Data.OracleClient

Imports System.Data.SqlClient

'链接Oracle

'cn = New SqlConnection(""Data Source=TNS名称;Persist Security Info=True;User ID=用户名;Password=密码;" ")

'Imports System.Data.OracleClient

'Dim oOracleConn As OracleConnection = New OracleConnection()

'oOracleConn.ConnectionString = ""Data Source=MyOracleDB; User Id=username; Password=passwd; Integrated Security=no; "

'oOracleConn.Open()

'链接SQL Server

'cn = New SqlConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=;")

'链接Access

'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

Public Class Fun_DataBase

Dim cn As OleDbConnection

Dim cm As OleDbCommand

Dim da As OleDbDataAdapter

Dim ds As DataSet

Dim db_path As String = "D:\Documents\Visual Studio 2013\Projects\VBnet1\VBnet1\Resources\Database1.mdb"

Function Fun_sql1(Str_sql As String, V_调用来源 As String) '按指定sql,反馈1个查询值

Try

'Dim cn As New OleDbConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=123456;")

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

cm = New OleDbCommand(Str_sql, cn)

cm.ExecuteNonQuery()

Dim strValue As String = cm.ExecuteScalar.ToString

'MessageBox.Show(strValue)

Fun_sql1 = strValue

cn.Close()

Fun_sql1 = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sql1 = False

End Try

End Function

Function Fun_sqln(Str_sql As String, V_调用来源 As String) '按指定sql,反馈1行n列查询值

Try

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

Dim cmd As New OleDbCommand("select * from grade", cn)

'Dim dr As SqlDataReader

Dim dr As OleDbDataReader

dr = cmd.ExecuteReader()

Dim strDisplay As String = ""

While dr.Read()

Fun_sqln = dr(0).ToString "|"

End While

cn.Close()

Fun_sqln = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sqln = False

End Try

'Dim s = Split(F.Fun_sqln("ef"), "|")

'Dim i As Integer

'i = UBound(s)

'For i = 0 To UBound(s)

' MessageBox.Show(s(i))

'Next

End Function

Public Function Fun_sql_exec(Str_sql As String, V_调用来源 As String) '执行指定sql,反馈T|F

Try

'链接Access

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_path ";Persist Security Info=False")

cn.Open() 'sql语句执行前,必须打开连接

cm = New OleDbCommand(Str_sql, cn)

cm.ExecuteNonQuery()

cn.Close()

Fun_sql_exec = True

Catch ex As Exception

MessageBox.Show(V_调用来源 ":执行sql语句失败!" Str_sql)

Fun_sql_exec = False

End Try

End Function

vb.net可以对access数据实现增删查改吗

1、VB.NET是一个高级程序设计语言

2、ACCESS是一个办公型的数据库

3、只要设置正确、代码完整是完全可以操作的

你好!有没有vb.net对SQL数据库进行增删改查的例子

一般都是vb.net传入参数 交给存储过程去做的 你是要在vb.net前台就执行的例子 还是想要调用存储过程的例子

前台的一般就是这样

Dim paras As New NameValueCollection

paras .Append("delete from T_AlarmConfig ")

paras .Append(" where AlarmConfigID=@AlarmConfigID")

调用存储过程的就是给写存储过程了,这是调用存储过程的例子,只能理解理解

''' summary

''' 删除数据

''' /summary

''' param name="procName"存储过程名/param

''' param name="paras"存储过程参数/param

''' remarks

''' 2006-5-29 zhuzh Created

''' /remarks

Public Sub DeleteData(ByVal procName As String, _

ByVal paras As NameValueCollection, _

Optional ByVal timeout As Integer = 30)

eventCount += 1

'存储过程参数名数组

Dim paraNames As String() = {}

'存储过程参数值数组

Dim paraValues As String() = {}

'传入的参数转化成数组

Me.ConvertNameValueCollection(paras, paraNames, paraValues, STATUS_UPDATE)

'判断系统类型调用相应模块的方法

If isWebSys Then

DeleteDelegateInstance = AddressOf webGw.ExecProc

Else

DeleteDelegateInstance = AddressOf AdoGw.ExecProc

End If

Dim ret As Integer = 0

Dim ds As New DataSet

'----guojun 2008-1-2 add-----

If timeout 60000 Then

timeout = 60000

End If

'--------防止超时异常--------

DeleteDelegateInstance.BeginInvoke(procName, ret, ds, paraNames, paraValues, timeout, _

AddressOf DataDeletedCallBack, Nothing)

End Sub


本文题目:关于vb.net增删的信息
转载源于:http://kswsj.cn/article/hsigps.html

其他资讯