Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 October 29th, 2004, 03:40 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default What is wrong with this code?

Hi
I have a simple form with 2 adodc data controls on them. I have used ODBC data source name instead of connectionstring in both cases.
Can nayone tell me what is wroing in the following code? It works perfectly if I use connection string but if I use ODBC it wont!!!
Thank in advance


Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

With Me.Adodc2
    .ConnectionString = Adodc1.ConnectionString
    If (pRecordset.EOF = True Or pRecordset.BOF = True) Then
        .RecordSource = "select * from Students where Klass_Number = 0"
    Else
        If (IsNull(pRecordset.Fields("Id").Value) Or IsEmpty(Adodc1.Recordset.Fields("Id").Value)) Then
            .RecordSource = "select * from Students where Klass_Number = 0"
        Else
            If (IsEmpty(pRecordset.Fields("Id").Value)) Then
                .RecordSource = "select * from Students where Klass_Number = 0"
            Else
                .RecordSource = "select * from Students where Klass_Number = " & pRecordset.Fields("Id").Value & " order by Last_Name"
            End If
        End If
    End If
    .CommandType = adCmdText
    .Refresh
    txtCA.Text = Round(CAv, 2)
    End With

    StudentDataGrid.Columns.Item(1).Width = 0
    Exit Sub

End Sub

 
Old November 4th, 2004, 09:04 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   I am a very beginning VB database coder, but an ODBC relies on the data source being configured on your machine beforehand, unless you create a system/file DSN earlier in your code. This is something I do with scripts I write that connect to databases using this method. That way I am sure the DSN is there, and I know what name to use to reference it.

   I hope this helps.

mmcdonal
 
Old January 28th, 2006, 08:20 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Hardwar, Uttranchal, India.
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Quote:
quote:Originally posted by SaharaWizard
 Hi
I have a simple form with 2 adodc data controls on them. I have used ODBC data source name instead of connectionstring in both cases.
Can nayone tell me what is wroing in the following code? It works perfectly if I use connection string but if I use ODBC it wont!!!
Thank in advance


Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

With Me.Adodc2
    .ConnectionString = Adodc1.ConnectionString
    If (pRecordset.EOF = True Or pRecordset.BOF = True) Then
        .RecordSource = "select * from Students where Klass_Number = 0"
    Else
        If (IsNull(pRecordset.Fields("Id").Value) Or IsEmpty(Adodc1.Recordset.Fields("Id").Value)) Then
            .RecordSource = "select * from Students where Klass_Number = 0"
        Else
            If (IsEmpty(pRecordset.Fields("Id").Value)) Then
                .RecordSource = "select * from Students where Klass_Number = 0"
            Else
                .RecordSource = "select * from Students where Klass_Number = " & pRecordset.Fields("Id").Value & " order by Last_Name"
            End If
        End If
    End If
    .CommandType = adCmdText
    .Refresh
    txtCA.Text = Round(CAv, 2)
    End With

    StudentDataGrid.Columns.Item(1).Width = 0
    Exit Sub

End Sub


Hi Friend..

I'm begginer for this field...
can you tell me sth that why should we use this procedure instead of
DSN. Does it has some advance feature.. Pls reply me





Dipu




Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with my code? DyerOppenheimer BOOK: Beginning Ajax with ASP.NET 0 January 7th, 2008 08:46 AM
What's wrong with this code? appleseed C++ Programming 2 November 25th, 2006 08:17 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 12:06 PM
What is wrong with code? rtr1900 Classic ASP Databases 1 April 3rd, 2006 03:20 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM





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