VB中如何查詢顯示資料庫表中的記錄

2022-07-01 11:21:45 字數 2997 閱讀 7449

1樓:匿名使用者

用陣列記錄,二次查詢

sql 在course 表中查詢到teacher_id=12345的所有記錄

用迴圈把course_id新增到陣列中,a()然後再迴圈開啟一個新的記錄集,sql在score表中查詢出course_id=a()的

我是這麼做的,不知道還有沒有高手提供其它方法

2樓:

建立記錄集物件,用data控制元件連結資料庫 執行select score.*,course.id,course.

teacher_id from ccore,course where score.course_id=course.id and course.

teacher_id='12345'

然後用迴圈輸出

do while not rs.eof

print ***

rs.movenext

loop

3樓:

distinct 表示得到的資料不顯示重複記錄,這裡的重複是指所有資訊的重複。只要有一個列不重複就不表示重複。

以下語句就是你想要的結果,如果這不是那隻能是我理解錯了,請再說明白一點。

select distinct b.id,b.teather_id from score a inner join course b on a.

course_id = b.id where b.teather_id ='12345'

在vb中,怎麼查詢一個資料庫表中的欄位記錄?

4樓:匿名使用者

那你用什麼方法連線資料庫的?

無非是從第1條記錄開始,做迴圈;

在列表框新增一個姓名

下移一條記錄

再在列表框新增一個姓名

再下移一條記錄

......

一直到資料表結束

如果用ado物件:

一般:rst.movefirst

do while not rst.eof

list1.additem rst.fields( "姓名")rst.movenext

loop

在vb怎麼查詢資料庫中的資料啊!

5樓:匿名使用者

查詢什麼資訊呀?有什麼欄位?

select * from 表1 where 客戶號 in (select 客戶號 from 表2 where 客戶表='" & 文字框1.text & "' and 訂單號='" & 文字框2.text & 「'」

vb中怎樣在文字框裡顯示資料庫表中的某一條記錄的欄位

6樓:

首先資料庫連線

第二去資料庫查詢select 國名 from info where 國名="中國"

把查詢將惡果填充textbox

vb怎麼獲取資料庫裡的記錄值

7樓:文件類共創空間

string selectsql="select * from admin where username='"+this.username+"'";

sqldataadapter ad=new sqldataadapter(selectsql,con);

dataset ds=new dataset(); //存放於記憶體中的資料快取

ad.fill(ds,"admin"); //管理員許可權

this.lable1.text=ds.table[0].row[0].["user_id"].tostring;

this.databinder();

8樓:迷今戀古

例如一個表info的欄位有:user,password,question,answer

dim cn as new adodb.connection '定義資料庫的連線

dim rs as new adodb.recordset

''''

這裡連線資料庫

''''

'查詢語句

sql="select * from info where user='賬號"

rs.open sql

rs.movefirst

pw=rs.fields(1).value '''這就是密碼

或者pw=rs.fields("password").value '''這就是密碼

9樓:匿名使用者

adoquery資料庫控制元件名

getlasttestno 屬性值存放變數

查詢語句:

adoquery.recordsource = "select * from " +查詢屬性等

查詢資料庫語句之後:

adoquery.refresh

if adoquery.recordset.recordcount = 0 then

else //查詢結果有記錄

//判斷查詢到的記錄中,所要找的屬性是否空值

if not isnull(adoquery.recordset.fields(屬性)) then

if adoquery.recordset.recordcount > 1 then

adoquery.recordset.movelast

//將對應的屬性值賦值給變數,查詢到多個記錄則顯示最後一個記錄

getlasttestno = adoquery.recordset.fields(dbinjno)

else

//只有一個記錄

getlasttestno = adoquery.recordset.fields(dbinjno)

end if

else

getlasttestno ="" //無記錄

end if

end if

將getlasttestno 顯示在控制元件上即可得到所要的屬性密碼值

vb中怎麼通過adodc刪除資料庫表中的所有資料

vb通過sql結構化查詢語句中delete子句,賦值給adodc資料控制元件的recordsource 屬性,來執行刪除資料庫一個表的所有記錄。recordsource 屬性,返回或設定data控制元件的基本表 sql語句。sql 語句 sql 中的以關鍵字打頭 完整描述一個操作的完整的短語。例如 ...

vb查詢access資料庫

private sub command1 click dim cn as adodb.connectiondim mysql as string dim myrs as adodb.recordsetcn.cursorlocation aduseclientcn.connectionstring d...

如何將資料庫中的表匯入到另外的資料庫中

你好以下是我以學生資訊表為例實現此方法,你可仿照我的例子。現在有這樣一張表message 包含兩列 teacher number student number teacher number包含1 20 student number包含21 300 格式比如 teacher number studen...