Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Accessing SQL2000 with VB 6 & CR 8.5 1

Status
Not open for further replies.

yjoke

Programmer
Feb 14, 2002
26
PT
I've been having 'lots of' troubles connecting my Visual Basic Crystal Report with an SQL Server 2000. Just today, after finishing some minor details on the code, I ran the program and it worked. But then I had to renamed a table on the DB and it started to give me an error that the (prior) table couldn't be found in the server. After awhile, I decided to rebuilt my VB CR from scratch... and now it still doesn't work. I'm getting kinda upset 'cause it's a part of a project that needs to be finished by 28/02/02. (this is one of five reports that need to be working)

Could anyone help me on this one. The code I used is the following:

Private Sub Form_Load()
Dim strSQL As String
Dim comando As String

strSQL = "SELECT " & _
"OBRA.FObraID, OBRA.fo_DataCriacao, OBRA.fo_horainicio, OBRA.fo_tecnicoID, " & _
"OBRA.fo_clienteID, OBRA.fo_kms, CLMES.NOME, CLMES.MORADA1, CLMES.TEL, " & _
"EPMES.NOME, Veiculo.veic_matricula, Veiculo.veic_codImob, OBRAITEM.ItemID, " & _
"OBRAITEM.descr, OBRAITEM.qtd, OBRAITEM.custo, OBRAITEM.codbarras, " & _
"Versao.versao_nome, Marca.marca_nome, Modelo.model_nome, CPOST.COD, CPOST.DESIG " & _
"From " & _
"TESTES.dbo_OBRA, TESTES.dbo.CLMES, TESTES.dbo.EPMES, TESTES.dbo.Veiculo, " & _
"TESTES.dbo_OBRAITEM, TESTES.dbo.Versao, TESTES.dbo.Marca, TESTES.dbo.Modelo, " & _
"TESTES.dbo.CPOST"

comando = "uid=agenda; pwd=testes; driver={SQL Server}; server=sql2000; database=TESTES; dsn= , ,connection=adConnectAsync"
Set Conn = New ADODB.Connection
Conn.Open comando

Set rec = New ADODB.Recordset
rec.Open strSQL, Conn, adOpenStatic, adLockReadOnly
Report.Database.LogOnServer "p2ssql.dll", "Sql2000", "TESTES", "agenda", "testes"

Screen.MousePointer = vbArrowHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub

My thanks to anyone who can give me a hand on this.
 
P.S.: I forgot to tell what error msg was appering. Here it goes:

Err:-2147217871
[Microsoft][ODBC SQL Server Driver] Timeout expired

Thank 'u in advance!
 
You don't do both a .LogonServer and create an ADO recordset. You do one or the other.

If you created an ADO recordset, just do a .SetDataSource to pass the recordset to the report. No .LogonServer necessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top