Mr. Mirtheil
i heartly appreciate your work (also to community who are beginner)
following is my code in vb6 as i said i am new in this
where i am connecting to pervasive verion 8 or higher
Dim CreateDept As Boolean
Dim GLServerName As String
Dim GLUserName As String
Dim GLPassword As String
Dim GLDatabase As String
Dim GLConnection As New ADODB.Connection
Private Sub CmdClo_Click()
Unload Me
End Sub
Private Sub cmdLogin_Click()
On Error GoTo Errhandler
If txtDatabaseName.Text = "" Or txtServer.Text = "" Then
MsgBox "Prduct Name <OR> Server Name <OR> Database Name cannot be empty"
Else
Dim str As String
str = "Provider=PervasiveOLEDB;Data Source=" & Trim(txtServer.Text) & ";UID=" & Trim(txtLogin.Text) & ";PWD=" & Trim(txtPwd.Text) & ";Initial Catalog=" & Trim(txtDatabaseName.Text) & ""
Dim ans As Boolean
GLServerName = Trim(txtServer.Text)
GLUserName = Trim(txtLogin.Text)
GLPassword = Trim(txtPwd.Text)
GLDatabase = Trim(txtDatabaseName.Text)
Set GLConnection = New ADODB.Connection
strconnect = str
GLConnection.ConnectionString = str
GLConnection.Open str
ans = True
Dim rs As New ADODB.Recordset
strsql = "select DocumentNumber From HistoryHeader where DocumentNumber<>'' and DocumentType=3 order by DocumentNumber"
rs.Open strsql, GLConnection, adOpenKeyset
If rs.RecordCount > 0 Then
Dim i As Integer
For i = 0 To rs.RecordCount - 1
cmbInvoice.AddItem rs!InvNumber, i
rs.MoveNext
Next i
End If
End If
Frame1.Visible = True
Set rs = Nothing
cmdLogin.Enabled = False
Exit Sub
Errhandler:
Dim enumber As Long ' Integer
enumber = Err.Number
MsgBox Err.Description, vbCritical + vbOKOnly, gstrMessage
Err.Clear
End Sub
Private Sub cmdPrint_Click()
Dim invnum As String
invnum = ""
If cmbInvoice.List(cmbInvoice.ListIndex) = "" Then
Exit Sub
Else
invnum = cmbInvoice.List(cmbInvoice.ListIndex)
End If
Set cmd = New ADODB.Command
cmd.ActiveConnection = GLConnection
cmd.CommandType = adCmdStoredProc
' cmd.CommandText = "[dbo].[InvDetailz]"
cmd.Parameters.Append cmd.CreateParameter("@InvNum", adVarChar, adParamInput, 20, invnum)
Set rs = cmd.Execute
Set cmd.ActiveConnection = Nothing
Dim str As String
str = "dsn=TEST02;uid=" & txtLogin.Text & ";pwd=" & txtPwd.Text & ";dsq=" & GLDatabase & ";"
Dim ans As Boolean
Set GLConnection = New ADODB.Connection
strconnect = str
GLConnection.ConnectionString = str
GLConnection.CursorLocation = adUseClient
GLConnection.Open str
Dim Repstr As String
Repstr = "" & GLServerName & ";" & GLUserName & ";" & GLPassword & ";DSQ=" & GLDatabase & ";"
CrystalReport1.Connect = str ' Repstr
CrystalReport1.ReportFileName = App.Path & "\PP_Invoice.rpt"
CrystalReport1.WindowShowPrintBtn = True
CrystalReport1.WindowShowPrintSetupBtn = True
CrystalReport1.WindowState = crptMaximized
CrystalReport1.Action = 1
CrystalReport1.Destination = crptToWindow
CrystalReport1.Reset
End Sub
Private Sub cmdShow_Click()
cmbInvoice.Clear
Dim rs As New ADODB.Recordset
strsql = "select DocumentNumber From HistoryHeader where DocumentNumber<>'' and DocumentType=3 and DocumentDate between '" & Format(DTPicker1.Value, "mm/dd/yyyy") & "' and '" & Format(DTPicker2.Value, "mm/dd/yyyy") & "' order by DocumentNumber"
rs.Open strsql, GLConnection, adOpenKeyset
If rs.RecordCount > 0 Then
Dim i As Integer
For i = 0 To rs.RecordCount - 1
cmbInvoice.AddItem rs!InvNumber, i
rs.MoveNext
Next i
End If
End Sub
Private Sub Command2_Click()
Unload Me
Beep
End Sub
Private Sub Form_Load()
Frame1.Visible = False
DTPicker2.Value = Format(DateTime.Now, "dd-MM-yyyy")
End Sub
requirement
-----------
1) how to connect to pervasive as per this code it is showing unspecified error where server name is defined as JAYESH-492A222F, User Name and Password is BLANK and Database is TEST02.
i had created DSN under ODBC as TEST02
2) how to write procedure where row has to match with different tables
select historyheader.currencycode, historylines.documentnumber, customermaster.customerdesc, currencyfile.fieldformat from historylines join historyheader on historylines.documentnumber = historyheader.documentnumber left join customermaster on historyheader.customercode = customermaster.customercode left join currencyfile on historyheader.currencycode = currencyfile.currcode where historyheader.documentnumber = @InvNum
kindly guide me to proceed further
waiting for your favourable reply