One of the strangest problems with VB database programming

Updated on technology 2024-05-20
6 answers
  1. Anonymous users2024-02-11

    Start with "Engineering" -- References, load the Microsoft ActiveX Data Library

    Then write **.

    public conn as new 'Define a connection to connect to the database.

    public rs as new 'Define a recordset to hold records.

    public strsql as string 'Used to store SQL statements.

    set "provider=;data source=" & "\;persist security info=false" 'Specify what database to connect to, as a relative path.

    Open the connection, and the database is connected.

    strsql="select * from table" 'Specify the SQL statement to query the table table, and how to write the SQL statement will not be discussed.

    strsql ,conn,3,3 'Open the data table.

    Add a new record to the table and write this line in the click event of the button.

    The name of the field").value= 'Assign a value to the field, and so on, write this line in the button's click event.

    set = rs 'Specify the data source of datagrid1.

    Use a for loop to specify the display of the data for the cells of DataGrid1.

    Specify the specific cell with the col and row attributes of datagrid1.

    That's the idea of refreshing, **write it yourself.**

    In addition, the record of datagrid1 will not be automatically paginated, and you need to write the pagination yourself**.

    You have not yet opened the database, or you have not connected to it at all, and the database must be opened first in order to operate on the database.

  2. Anonymous users2024-02-10

    First of all I suggest you change the design of your database's tables:

    Create three tables.

    Table 1: Self-increment number, student number, course number, credit.

    Table 2 Student number, name, age.

    Table 3 Course Number, Course Name.

    Why create three tables? First of all, if you think about it, if there is a course called "Advanced Mathematics", and there is only one student in this course, but for various reasons, this student drops out, and then the student's student number is deleted, and the problem comes, because only this student takes the "Advanced Mathematics" course, and there is no information about the "Advanced Mathematics" course in the database after the student is deleted.

    Why are there self-incrementing numbers in Table 1? That's because a student can choose from a lot of courses, designed to ensure the uniqueness of the keywords in the database.

    Left join returns all rows in the "first table", although there is no matching data in the "second table".

    Right Join returns all rows in the "second table", although there is no matching data in the "first table".

    The result set returned by inner join is all matching data from both tables.

    Table 1 is Table 1, Table 2 is Table 2, and Table 3 is Table 3

    The language is written according to the designed table.

    select credits.

    from table1 inner join table2 on table1.Student ID=table2Student ID inner join table3 on table1

    Course code = table3Course number.

    where table1.Student ID=2 and Name='Reese'and Course Name='English'

    Below is the diagram. <>

  3. Anonymous users2024-02-09

    There is a problem with the form you provided, why does Table 1 do not have a student number, what if the student's name is the same?

    In addition, there is also a problem with the query you provided, how can there be such a logic, query by course, age.

    According to your requirements, the answer is as follows:

    select

    from Table 1 a

    inner join table 2 b on aStudent ID = BStudent ID.

    where course = var course and age = var age.

  4. Anonymous users2024-02-08

    The idea on the first floor is correct, but Table 1 does not have a student number, and it can only be corrected unless it is added.

    Correction on the first floor, it can be seen who did not arrange the course.

    select

    from Table 1 a

    right join Table 2 b on aName = bName.

    where course = var course and age = var age.

  5. Anonymous users2024-02-07

    This one is about variable scoping.

    VB can be used directly without declaring variables, so if you want to use the same variable in different subroutines, you need to declare global variables, and if you don't declare it, you need to use it directly, and it will be handled by local variables with different effects in each subprogram, resulting in unexpected results.

    That's the case with this problem, because the variable a is defined in the generic declaration, so the scope of a is the whole program, and its value is always retained, in the button event, it is first assigned as 2, and when the test subroutine is called twice, it is calculated as 3 and 4 respectively, and b, c, because it is not defined in the generic declaration, so the b and c in the button event are the corresponding variables b and c with the same name as the test subroutine, which are not actually a variable, they are all local variables, It only works in the respective subroutines. In the process of calling the test subroutine, the default initial value of 0 is reassigned each time, and then 1 is calculated by +1, so the result of the print is.

    If you're writing your own program, it's a good idea to ask for mandatory variables to avoid such unexpected results.

    That is, use option explicit on

    Or option explicit

  6. Anonymous users2024-02-06

    VB's database application is written:

    VB provides:

    ADO (ActiveX Data Object), a new data access technology with features such as: a simpler object model; with other Microsoft and non-Microsoft

    better integration of technologies; a common interface for local and remote data data; remotely accessible and disconnected recordsets; user-accessible data binding interfaces; and recordsets for hierarchies.

    The ADO Data control, is a new, OLEDB-aware data source control that functions with the internal Data control and Remote Data

    The controls are very similar in that they allow you to create a database application with minimal **.

    The connection to the database is achieved through the data objects or controls described above.

    In Visual Basic, you can already bind any ADO OLE DB data source to any ADO OLE DB data consumer. At runtime, you can set the controls.

    datasource property to dynamically bind the control to the data source. You can create classes that serve as data sources and data consumers, and through a new BindingsCollection

    Objects bind these classes together. You can create a user control that is similar to an ADO data control and serves as a data source.

    Use a certain data control to display the contents of the data table.

Related questions
20 answers2024-05-20

There is no bottom in select

select top 1 * from table order by field 1 desc" >>>More

2 answers2024-05-20

sql2000

In the start-program-microsoftsqlserver-enterprise manager interface, open the console root file and record all the numbers to (local) (windowsnt), which has the database, data conversion service. Wait, you can right-click "New Database" in "Database" and you're done. >>>More

8 answers2024-05-20

MySQL is unfamiliar, but the idea of database creation is the same: >>>More

13 answers2024-05-20

on error resume next

connstr="dbq="+"")+";defaultdir=;driver=;" >>>More

15 answers2024-05-20

If the bonus is empty, then your salary plus bonus sal+comm is also empty. >>>More