㈠ VB.NET 查詢資料庫內容
Try
gogoodsinfo.View(" where 商品編號='" + TextBox1.Text.replace("'","''") + "'")
Catch ex As Exception
messagebox.show("錯誤信息:"+ex.tostring(),"提示")
End Try
你試一下,把我這句給復制過去看是否報錯,左邊條件要有空格,右邊要有取代函數!
㈡ vb.net資料庫查詢
select * from 表 where
(case when 條件 then 1 else 0 end+
case when 條件 then 1 else 0 end+
case when 條件 then 1 else 0 end+
case when 條件 then 1 else 0 end+
case when 條件 then 1 else 0 end) BETWEEN 2 and 5
㈢ VB.NET 查詢SQL資料庫
sql伺服器上需要有裝oracle的client端(或者類似驅動)
2. 在sqlserver的企業管理器里建一個鏈接伺服器(DBlink)具體方法可以查一下幫助
3.
insert into sqlserver_table
select * from openquery(你建的dblink名稱,'oracle的select語句')
openquery的語法可以查幫助出來
注意select語法是跟oracle的,要用引號括起來當字元串,ms要大寫
很久之前做過的,希望能幫上,試試看吧:)
另外,虛機團上產品團購,超級便宜
匿名 ??<span class="tm">7-21 02:14</span>
</p>
<div class="b bt2"><div class="bt bg1 ft"><img alt="其他答案" height="16" src="/static/img/ico2.gif" width="16"/>其他答案</div></div>
<p class="ft p1">1. sql伺服器上需要有裝oracle的client端(或者類似驅動)
2. 在sqlserver的企業管理器里建一個鏈接伺服器(DBlink)具體方法可以查一下幫助
3.
insert into sqlserver_table
select * from openquery(你建的dblink名稱,'oracle的select語句')
openquery的語法可以查幫助出來
注意select語法是跟oracle的,要用引號括起來當字元串,ms要大寫
很久之前做過的,希望能幫上,試試看吧:)
㈣ 在vb.net中如何查詢MDB資料庫的數據
以下是完整模塊
Imports System.Data
Imports System.IO
Imports System.Data.OleDb
Mole Mole1
Public cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\mdb資料庫名字.mdb") '定義連接
Public DataBaseRST As Integer '用來返回資料庫執行結果
Public Function DataModify(ByVal str As String) As Boolean '進行資料庫修改操作
Dim cmdinsert As New OleDbCommand
Try
cmdinsert.CommandText = str
cmdinsert.Connection = cn
If cn.State = ConnectionState.Closed Then cn.Open()
DataBaseRST = cmdinsert.ExecuteNonQuery() '用來返回執行的結果
cn.Close()
Return True
Catch ex As Exception
MessageBox.Show(Err.Description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function
Public Function Search(ByVal str As String, ByVal DGV As DataGridView) As Boolean '查詢 str---查詢命令,DGV---DataGridView,用來顯示數據的控制項
Dim tb As New DataTable
Try
Dim ap As New OleDb.OleDbDataAdapter(str, cn)
ap.Fill(tb)
DGV.DataSource = tb
Return True
Catch ex As Exception
MessageBox.Show(Err.Description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function
End Mole
'以下是調用方法
DataModify(" insert into aa values ('1','2')")'-------這里是資料庫更新操作
Search("select bb from aa",DataGridView1)'-----------這里是數據表查詢操作
㈤ vb.net 資料庫查詢
這是你的全部嗎?
首先連接資料庫連接了嗎?Sqlconnection的定義,然後在後面填寫你要連接的資料庫,以及用戶名和密碼
Dim sqlcon As New SqlConnection("Data Source=WWW-9A6F5E15ECC;Initial Catalog=gj;User ID=sa;Password=123")
sqlcon.Open()
然後這是VB.NET嗎?
語法就有問題
dim sql as string = "select max('id') as zd from 基本信息 where 子類='客商'"
dim sqlcmd as new sqlcommand(sql, sqlConnection1)
這些,再就是sql語句max(參數)
還有你想做什麼。。你這表怎麼樣的。。始終覺得有點問題
㈥ VB.NET連接ACCESS資料庫,讀取查詢並顯示
給你寫個例子,不明白,再問!!
'引入OLEDB命令空間
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'定義一個OLEDB連接並實例化它
Dim con As New OleDbConnection
'定義一個OLEDB命令並實例化他
Dim cmd As New OleDbCommand
'定義一個OLEDBReader方法來讀取資料庫
Dim dr As OleDbDataReader
'初始化con的連接屬性,使用OLEDB模式,數據源為:你指定下路徑,我的是在D盤
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\dataSample.mdb"
'打開OLEDB數據連接
con.Open()
'初始化OLEDB命令的連接屬性為con,這個需要你理解下
cmd.Connection = con
'初始化OLEDB命令的語句 就是查詢 什麼欄位從什麼表 條件是ID等於你在t1中輸入的內容
cmd.CommandText = "select keyss from table1 where ID=" & t1.Text & ""
'執行OLEDB命令以ExecuteReader()方式,並返回一個OLEDBReader,賦值給dr
dr = cmd.ExecuteReader()
'判斷下dr中是否有數據。如果有就把第一個值賦值給t2的值
If dr.Read() Then
t2.Text = dr(0)
End If
'完成後關閉dr.con等釋放資源
dr.Close()
con.Close()
End Sub
End Class
㈦ vb.net 中如何使用SQL語句查詢資料庫
我是這樣做的:
Dim ConnectionString As String = _
"Provider=Microsoft.Jet.OleDb.4.0;_DatacSource = App.Path+\temp.mdb"
Dim myconn As OleDbConnection = New OleDbConnection()
myconn.ConnectionString = ConnectionString
Dim strcom As String = "select * form 通訊錄"
OleDbConnection1.Open()
Dim strdele As String="DELTEL 表 WHERE 姓名='MMM'"
Dim mycommand As OleDbCommand = New OleDbCommand(strdele, myconn)
mycommand.ExecuteNonQuery() '從資料庫中刪除記錄
DataSet1.Tables("通訊錄").Rows(mybind.Position).Delete() '邏輯刪除
DataSet1.Tables("通訊錄").AcceptChanges()
OleDbConnection1.Close()
㈧ VB.NET實現sql查詢問題
實在看不下去了,
Const sql As String = "select * from 學生基本信息表 where 學號='" & textbox1.Text & "'"
Const searchsql As String = "insert into 學生基本信息表 values('"
Dim xh As String , name As String , sex As String , id As String , tel As String , address As String
Dim time As DateTime
Dim conn as new adodb.connection
dim ConnectionString as string
If textbox1.Text = "" Or textbox2.Text = "" Then
MsgBox "該生信息不完整"
Else
ConnectionString = "Data Source=ZX\SQLEXPRESS;Initial Catalog=studentMIS;Integrated Security=True"
conn.Open(ConnectionString)
cmd.CommandText = sql
cmd.Connection = conn
sqlda.SelectCommand = cmd
Try
dr = cmd.ExecuteReader()
Do While dr.Read()
MsgBox("該生信息已存在")
Loop
If dr.Read = False Then
xh = textbox1.Text
name = textbox2.Text
sex = cb1.SelectedItem
time = textbox3.Text
id = textbox4.Text
tel = textbox5.Text
address = textbox6.Text
searchsql = searchsql & xh & "','" & name & "','" & sex & "','" & time & "','" & id & "','" & tel & "','" & address & "')"
cmd.CommandText = searchsql
sqlda.SelectCommand = cmd
sqlda.Fill(ds, "學生基本信息表")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
按F8一句句調試看那句不對
㈨ vb.net 中如何使用SQL語句查詢資料庫中的數據
1、首先打開Visual Studio 2008代碼窗口,添加引用。
㈩ 關於vb.net 資料庫查詢
'各項查詢條件為空的時候用 1=1來代替
'例如:
tmpSelIDStr=Trim(txtSelectId.Text)
if tmpSelIDStr="" then
tmpSelIDStr=" 1=1 "
Else
tmpSelIDStr=" 員工編號='" & tmpSelIDStr & "'"
End If
'同理其它的都這么處理
'最後合並起來
sqlstr="select ..... from .... where " & tmpSelIDStr & " and " & tmp ....
'不知道這樣回答你是否可以理解