Component building in VB

Results 1 to 2 of 2

Thread: Component building in VB

  1. #1
    Srilatha Guest

    Default Component building in VB

    I am trying to build a simple component to query from a SQL database.can someone tell me what&#039s wrong with this code snippet -<BR><BR>Private cn As ADODB.Connection<BR><BR>Private Sub OpenConnection()<BR>Set cn = New ADODB.Connection<BR>cn.ConnectionString = _<BR>"Provider=SQLOLEDB;" & _<BR>"Data Source=ZMY12-5208;" & _<BR>"Initial Catalog=MKCDB;" & _<BR>"User ID=sa;" & _<BR>"Password="<BR>cn.Open<BR>End Sub<BR>Private Sub CloseConnection()<BR>If cn.State &#060;&#062; 0 Then cn.Close<BR>Set cn = Nothing<BR>End Sub<BR><BR>Public Function RecordCount()<BR>OpenConnection<BR>/* here I set my sql statement and execute it */<BR>CloseConnection<BR>End Function<BR><BR>When I try to test this in vb giving <BR>Set obj = New MKCDB.RecordCount<BR>receive a user-defined type not defined compile error.<BR>I am very new to VB.<BR>Pls. help me figure this out.<BR>Thanks,<BR>Srilatha<BR>

  2. #2
    sachink Guest

    Default RE: Component building in VB

    try this <BR>Set obj = New MKCDB<BR>x=obj.RecordCount<BR>Also try changing the name Recordcount.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts