Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2007, 07:10 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default Database Connectivity


Dear Member,

 1. I am having a form with fields such as Customer Number (AutoNumber),Job Assigned to, department, Job Status, feedback Status, Completion Date, Pending etc.I was unable to connect to the DB.I have writeen a code as:

Code:
Public Sub DataConnect()
Dim myConnection As New Connection
Dim myREcordset As New Recordset

Set myConnection = New Connection
myConnection.ConnectionString = _
"PROVIDER=MSDataShape;" & _
"Data PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & MyDatabaseFile & ";" & _
"Persist Security " & _
"Info=False"
myConnection.CursorLocation = adUseClient
myConnection.Mode = adModeReadWrite
myConnection.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=test;UID=root;PASSWORD=default"
myConnection.Open
End Sub
Is this Correct?

2. Aaother doubt is that In another form, I am having fields like Operator Name, Select Technician and a Button for Get details.The other two are combo boxes.When a field (Number) is selected the Button gets enabled.(When the form is loaded the button is disabled).
I am unable to do it? when I select a number from the Combo Box, nothing happens.The Code which I wrote is

Private Sub Combo1_Change()
 If Combo1.Text = " " Then
 Command3.Enabled = True
 frmtimer.Show
 Unload Me
End If
End Sub

Any help will be appreciated............







 
Old February 14th, 2007, 11:48 PM
Registered User
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lord_jawad@hotmail.com
Default

Well friend if u are using ADO (as i think) then why need to use two time NEW operator in order to create a new connection

Public Sub DataConnect()

Dim myConnection As New Connection
Dim myREcordset As New Recordset

Set myConnection = New Connection



----- Instead you could use a single statement

dim cn as new adodb.connection
dim rst as new adodb. recordset

dim connString as string
dim strSQL as string

connString = "xyz;xyz;xyz"
strSQL = "SELECT * FROM [tblName]"


cn.connectionstring = connString
cn.open

set rst = strSQL,cn

.....
cn.close
------------------------------------------------------------



Jawad Hasan
 
Old February 15th, 2007, 02:31 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default


Thanks for the reply.I will try. But what about the second query?


Nandan




Quote:
quote:Originally posted by [email protected]
 Well friend if u are using ADO (as i think) then why need to use two time NEW operator in order to create a new connection

Public Sub DataConnect()

Dim myConnection As New Connection
Dim myREcordset As New Recordset

Set myConnection = New Connection



----- Instead you could use a single statement

dim cn as new adodb.connection
dim rst as new adodb. recordset

dim connString as string
dim strSQL as string

connString = "xyz;xyz;xyz"
strSQL = "SELECT * FROM [tblName]"


cn.connectionstring = connString
cn.open

set rst = strSQL,cn

.....
cn.close
------------------------------------------------------------



Jawad Hasan
 
Old February 15th, 2007, 03:17 AM
Registered User
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lord_jawad@hotmail.com
Default

Your 2nd query is not quite clear.
Well if u give full detail then it will be more helpful in answering

Just for try check/replace the critera
If Combo1.Text = " " Then

If Combo1.Text = "" Then (Remove extra space b/w quotes)

Well clear what u want

Jawad Hasan
 
Old February 15th, 2007, 05:53 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default

What I wanted is as Follows: I am having a form in which I have three comboBoxes, and as many number of textboxes and a CommandButton.The fields I am having in the form are : Operator name (ComboBox), Complaint Number (ComboBox), a Button near by (Called "Get Details").When the form is loaded, the Command button will be disabled. On selecting a value from the Complaint Number, then only this button gets enabled. The other fields are in a frame.Like Customer NAme, Dept/Area, Area of Complaint, Details of complaint (multiline textbox), telephone and E-mail Id. These fields will be locked, so that editing will not be possible.These datas are taken from DB.The main idea of this form is that when a complaint is received from the customer,that is first received in the form and from there it is send to the DB. There are two more Comboboxes. One for selecting the Technician to whom the particular task has been assigned and another for the Date and Time (System Date n time will be captured).

Hope now u r clear about the query/.

Nandan

 
Old February 15th, 2007, 03:02 PM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default


hai...Friend, I tried this also.But not working.
Any other way...


cnkumar74






Quote:
quote:Originally posted by [email protected]
 Your 2nd query is not quite clear.
Well if u give full detail then it will be more helpful in answering

Just for try check/replace the critera
If Combo1.Text = " " Then

If Combo1.Text = "" Then (Remove extra space b/w quotes)

Well clear what u want

Jawad Hasan
 
Old February 15th, 2007, 03:10 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I dont understand your logic.

This statement: If Combo1.Text = " " says: if the text value of the combo box is a blank space do something
This statement: If Combo1.Text = "" says: if the text value of the combo box is empty do something

What exactly do you need this logic to do?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
 
Old February 16th, 2007, 12:52 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default

Dear friend,

What I wanted is as Follows: I am having a form in which I have three comboBoxes, and as many number of textboxes and a CommandButton.The fields I am having in the form are : Operator name (ComboBox), Complaint Number (ComboBox), a Button near by (Called "Get Details").When the form is loaded, the Command button will be disabled. On selecting a value from the Complaint Number, then only this button should be enabled. The other fields are in a frame.Like Customer Name, Dept/Area, Area of Complaint, Details of complaint (multiline textbox), telephone and E-mail Id. These fields will be locked, so that editing will not be possible.These datas are taken from DB.The main idea of this form is that when a complaint is received from the customer,that is first received in the form and from there it is send to the DB. There are two more Comboboxes. One for selecting the Technician to whom the particular task has been assigned and another for the Date and Time (System Date n time will be captured).



cnkumar74






Quote:
quote:Originally posted by dparsons
 I dont understand your logic.

This statement: If Combo1.Text = " " says: if the text value of the combo box is a blank space do something
This statement: If Combo1.Text = "" says: if the text value of the combo box is empty do something

What exactly do you need this logic to do?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
 
Old February 16th, 2007, 01:00 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default


Dear Friend,
The logic I wanted to perform here is to enable a button when a value is selected from the ComboBox, which is disabled when the form is first loaded.On clicking this button, a MsgBox should popup,asking whether You want to display the details of the Customer.If the button clicked is "Yes", then the details should be displayed and if the answer is No, then not to display the details.

Hope u r clear with the logic.

cnkumar74







Quote:
quote:Originally posted by dparsons
 I dont understand your logic.

This statement: If Combo1.Text = " " says: if the text value of the combo box is a blank space do something
This statement: If Combo1.Text = "" says: if the text value of the combo box is empty do something

What exactly do you need this logic to do?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
 
Old February 16th, 2007, 05:39 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default


[Font = Verdana][blue]Dear Member

     I have a DB called Customer. There are some fields and some values, which have been entered through a form (NOt really).Now I wanted to capture or write back the datas from the DB to the form.How can I accomplish this task?. URGENT......Please give me the code for this task.


              Nanda Kumar,/blue]
              [Font]







Quote:
quote:Originally posted by dparsons
 I dont understand your logic.

This statement: If Combo1.Text = " " says: if the text value of the combo box is a blank space do something
This statement: If Combo1.Text = "" says: if the text value of the combo box is empty do something

What exactly do you need this logic to do?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
database connectivity singh.mandeep82 Struts 0 December 29th, 2007 05:22 PM
Database Connectivity asearle XSLT 4 October 16th, 2006 06:41 AM
Database Connectivity pageturner71 Access 1 September 8th, 2004 05:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.