-
private conn as new
private rs as new
private sub command1_click()
dim sqlstr as string
dim a as string
sqlstr = "select * from students where s_name='" & "'"
set rs =
if and then
elsea = rs("s_id") 'Assign the identified student number to variable a
Displays the student's student ID for **.
end if
end sub
private sub form_load()
Access database connection mode.
dim datapath as string
datapath = & "\" 'Database path.
provider=;data source=" & datapath & ";mode=readwrite|share deny none;persist security info=false"
SQL Server connection mode.
dim serverip as string, username as string, password as string, dataname as string
serverip = "" 'ip
username = "linhaibo" 'Username.
password = "pass" 'Password.
dataname = "linhaibo" 'The name of the database.
driver=; database=" & username & "; uid=" & username & "; pwd=" & password & "; server=" & serverip
end sub
private sub form_unload(cancel as integer)
on error resume next
set conn = nothing
end sub
-
First, if the data you retrieve from the database is stored in the recordset rd, and the field with the name in the database table is picname, do while not"picname") 'You can take out the name of **, so that the ** is loaded into image1'The recordset is moved down by one point, that is, the next **name loop is taken again
-
To output the SQL query result, directly manipulate the RS object and retrieve its field content.
rs(0) rs(0)
-
Define a recordset variable to accept data.
dim rst as new
select lpwd from tblogin where lid=userid"
mm=rst("ipwd").value
It can also be written like this:
select lpwd from tblogin where lid=userid"
set rst=
mm=rst("ipwd").value
-
Use a recordset and then access it through a recordset.
-
1. First of all, the most basic assignment is the default value.
2. Then you can also query and assign values to variables through the data table, as shown in the data table shown in the following figure.
3. You can directly assign values to variables through the select statement.
4. After the assignment, you can output it to see the result.
5. Then you can see that the result is the same as the value of the data table.
6. Finally, the more commonly used is the set method of assigning.
-
You can't, you can use the @aa as an out argument and use sp executesql
declare @database_name varchar(30), aa nvarchar(10)
select_sql varchar(200), update_sql varchar(200)
set @database_name = 'test'
Query statements. set @select_sql = ('select top 1 @aa=aa from ['+@database_name+'].[dbo].[test]')
Update the statement. set @update_sql = ('update ['+@database_name+'].[dbo].[test] set aa = null')
The output parameters @aa
exec sp_executesql @select_sql, n'@aa nvarchar(20) out', @aa out
if @aa is not null begin execute (@update_sql) end
-
set @select_sql = ('select top 1 aa from ['+@database_name+'].[dbo].[test]')
The sentence was changed to:
set @select_sql = ('select top 1 @aa=aa from ['+@database_name+'].[dbo].[test]')
set @aa = (execute (@select sql)) * keyword'execute'There are grammatical errors nearby. */
The sentence was changed to:
execute (@select sql) * keyword'execute'There are grammatical errors nearby. */
-
If you use adodb: x=rst(0).
If nuclear fibrillation you use: x=
The details changed to the degree of 100 wide faction adodb and.
-
Select max (field) from the table
Field values. If possible, check that the vb is connected to the database table.
-
f1="So-and-so"
f2=123
sql="select * from table name where field1='" & f1 & "'and Field2=" & f2
sql2008 statement:
select name = case when num = 1 then a else''end, grades, subjects. >>>More
select * from log a,(select ,max(date) from logwhere id='10000' >>>More
For example, the name of your table is a
select a.Name, aGrades as Language, BGrades as Mathematics. >>>More
selecta, sum(c)fromtablegroupbya.
It can solve the problem you said. >>>More
Since you don't know the primary key in your t hy cus install table, it's safer to use exists. >>>More