使用插入和更新在数据库中传递未填充的值. [英] passing a unfilled value in database using insert and update.
本文介绍了使用插入和更新在数据库中传递未填充的值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,可以在其中输入一些数据.我该如何编码这些东西?我使用了插入和更新查询.值类型为double,整数和字符串.
I have one problem in which I can enter some data to the database. How can I code this things? I used Insert and update query. The values types are double,integer and also string.
推荐答案
您尝试过的方法?
这里是提供用于执行插入/更新命令的示例代码
What you tried??,
Here am Providing the sample code for executing insert/update commands
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim cnn As OleDbConnection
Dim cmd As OleDbCommand
Dim sql As String
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"
sql = "Your SQL Statement Here"
cnn = New OleDbConnection(connetionString)
Try
cnn.Open()
cmd = New OleDbCommand(sql, cnn)
cmd.ExecuteNonQuery()
cmd.Dispose()
cnn.Close()
MsgBox(" ExecuteNonQuery in OleDbConnection executed !!")
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
End Sub
结束类
如果需要将空值传递给数据库,请使用DBNull
.
If you need to pass a null value to a database, use DBNull
.
这篇关于使用插入和更新在数据库中传递未填充的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文