<< Chapter < Page Chapter >> Page >

Khi đối tượng rdoResultset được tạo ra, ta có thể di chuyển đến mẩu tin xác định bằng các phương thức MoveFirst, MoveLast, MoveNext, MovePrevious.

Đối tượng rdotable

Đối tượng này xác định một bảng trong một nguồn dữ liệu ODBC. Đối tượng này không được sử dụng cho các thao tác truy xuất dữ liệu mà nó chỉ được sử dụng khi ta cần xác định cấu trúc các bảng của cơ sở dữ liệu của ta.

Đối tượng rdoparameter

Đối tượng này xác định các tham số đầu vào hay các kết quả nhận được từ các thủ tục lưu trữ sẵn trong cơ sở dữ liệu.

Sử dụng rdo trong chương trình

Thiết lập kết nối đến nguồn dữ liệu

  • Trước tiên ta phải tham chiếu đến mô hình đối tượng RDO.
  • Nối kết đến nguồn dữ liệu nhờ đối tượng rdoConnection.

- Khai báo một biến đối tượng rdoConnection.

- Khởi tao đối tượng, sau đó thiết lập các thuộc tính và các phương thức thích hợp để hoàn tất kết nối; trong đó có hai thuộc tính cần quan tâm là chuỗi kết nối (ConnectionString) và loại con trỏ (Cursor Driver).

  • Thiết lập nối kết nhờ phương thức EstablishConnection của đối tượng rdoConnection.

Chuỗi kết nối (odbc connect string)

Chuỗi kết nối được sử dụng khi thiết lập nối kết đến nguồn dữ liệu. Đây là một chuỗi (String) xác định các thông tin quan trọng gởi đến trình điều khiển ODBC để truy cập dữ liệu. Các thông tin cần quan tâm: tên nguồn dữ liệu (DSN Name), User ID, Password.

Các tham số của chuỗi kết nối ODBC:

Tham số Ý nghĩa
DSN Tên nguồn dữ liệu ODBC
UID Tên người dùng cơ sở dữ liệu
PWD Mật khẩu truy cập
DRIVER Trình điều khiển DBC
DATABASE Tên của cơ sở dữ liệu được nối kết
SERVER Tên máy chứa cơ sở dữ liệu phục vụ (database server)
WSID Tên máy chứa cơ sở dữ liệu khách (database client)
APP Tên của tập tin chương trình (*.exe)

Chuỗi kết nối được xác lập nhờ thuộc tính Connect của đối tượng rdoConnection.

Ví dụ: Chuỗi nối kết đến 1 DSN của cơ sở dữ liệu Access Biblio:

Set m_Connection = New RDO.rdoConnection

m_Connection.Connect = "DSN=Biblo"

m_Connection.EstablishConnection

Chuỗi nối kết đến DSN Publications của cơ sở dữ liệu SQL Server:

Set m_Connection = New RDO.rdoConnection

m_Connection.Connect = "DSN=Biblo;UID=sa;PWD=;"

m_Connection.EstablishConnection

Bên cạnh nối kết chuẩn thông qua ODBC, RDO cũng hỗ trợ loại nối kết DSN cấp thấp (DSN-less connection). Đối với loại này, ta không cần định nghĩa tên nguồn dữ liệu (DSN) trong bộ quản trị ODBC của Windows. Lúc này tất cả các thông tin về cơ sở dữ liệu được cung cấp đầy đủ trong chuỗi nối kết.

Ví dụ: Chuỗi nối kết cấp thấp đến cơ sở dữ liệu SQL Server Pubs:

Set m_Connection = New RDO.rdoConnection

m_Connection.Connect ="DRIVER={SQL Server};”&_

“SERVER=(local);DATABASE=Pubs;UID=admin;PWD=;DSN=;"

m_Connection.EstablishConnection

Trình điều khiển con trỏ (cursor drivers)

Trình điều khiển con trỏ xác định cách thức tập các mẩu tin trả về từ cơ sở dữ liệu được lưu trữ như thế nào, có thể chúng được lưu trữ tại máy chủ (server) hay máy trạm (client).

Trình điều khiển con trỏ được thiết lập nhờ thuộc tính CursorDriver của đối tượng Connection (trước khi gọi thực thi phương thức EstablishConnection) và các giá trị sau có thể đề cử cho nó:

Giá trị Ý nghĩa
rdUseIfNeeded Trình điều khiển ODBC tự động xác định loại con trỏ (được lưu phía server hay client). Nếu có thể, con trỏ loại được lưu phía server được đề cử.
rdUseODBC Xác định loại con trỏ của ODBC chuẩn, nghĩa là tập tất cả các mẩu tin được lưu ở máy client.
rdUseServer Tập các mẩu tin được lưu phia server. Tuy nhiên loại con trỏ này không thích hợp lắm trong môi trường đa người dùng.
rdUseClientBatch Giống như rdUseODBC nhưng có thể được cập nhật đồng thời.
rdUseNone Không sử dụng con trỏ, tập các mẩu tin được trả về một lần duy nhất lúc chúng được yêu cầu. Ta chỉ có thể di chuyển tới trong tập các mẩu tin kết quả.

Questions & Answers

what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
What would be the best educational aid(s) for gifted kids/savants?
Heidi Reply
treat them normal, if they want help then give them. that will make everyone happy
Saurabh
What are the treatment for autism?
Magret Reply
hello. autism is a umbrella term. autistic kids have different disorder overlapping. for example. a kid may show symptoms of ADHD and also learning disabilities. before treatment please make sure the kid doesn't have physical disabilities like hearing..vision..speech problem. sometimes these
Jharna
continue.. sometimes due to these physical problems..the diagnosis may be misdiagnosed. treatment for autism. well it depends on the severity. since autistic kids have problems in communicating and adopting to the environment.. it's best to expose the child in situations where the child
Jharna
child interact with other kids under doc supervision. play therapy. speech therapy. Engaging in different activities that activate most parts of the brain.. like drawing..painting. matching color board game. string and beads game. the more you interact with the child the more effective
Jharna
results you'll get.. please consult a therapist to know what suits best on your child. and last as a parent. I know sometimes it's overwhelming to guide a special kid. but trust the process and be strong and patient as a parent.
Jharna
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Giáo trình visual basic. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10777/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Giáo trình visual basic' conversation and receive update notifications?

Ask