Click here to Skip to main content
15,887,683 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Call function in VBA (Access 2007) Pin
misCafe21-Jan-10 13:19
misCafe21-Jan-10 13:19 
QuestionExport folder directory listing to Excel with Hyperlinks Pin
cavana120-Jan-10 4:11
cavana120-Jan-10 4:11 
AnswerRe: Export folder directory listing to Excel with Hyperlinks Pin
Steven J Jowett20-Jan-10 7:08
Steven J Jowett20-Jan-10 7:08 
QuestionGetpicture method in ocx Pin
Mohamed Asane19-Jan-10 21:39
Mohamed Asane19-Jan-10 21:39 
AnswerRe: Getpicture method in ocx Pin
Estys20-Jan-10 2:14
Estys20-Jan-10 2:14 
GeneralRe: Getpicture method in ocx Pin
Mohamed Asane20-Jan-10 17:39
Mohamed Asane20-Jan-10 17:39 
GeneralRe: Getpicture method in ocx Pin
Estys21-Jan-10 2:05
Estys21-Jan-10 2:05 
QuestionVB + OleDb.OleDbCommand + MS Access issue. Pin
alexvw19-Jan-10 9:23
alexvw19-Jan-10 9:23 
Hello there,

I have an MS Access query that works as expected from its UI, but when invoked from vb app using OleDb.OleDbCommand it does not. This is problaby silly, but I can't get around it. Could somebody kindly offer some advice?

Here is the query def:
SELECT [Id_UCAB], Sum([Copias]) AS Cant, ([Paginas]*Sum([Copias])) AS CantPag
FROM PrintedDocs AS A, Docs AS B
WHERE A.DocId=B.DocId And (Id_UCAB Like IIf(ISNULL([@DocId]),Id_UCAB,[@DocId]) And (Fecha>=IIf(ISNULL([@FechaIni]),Fecha,[@FechaIni]) And Fecha<=IIf(ISNULL([@FechaFin]),Fecha,[@FechaFin])))
GROUP BY [Id_UCAB], [Paginas]
ORDER BY IIf([@OrdCod]=1,[Id_UCAB],([Paginas]*Sum([Copias])));

As you can see it has 4 optional parameters that are requested by Access in the following order: @DocId, @FechaIni, @FechaFin, @OrdCod.

When I invoke it from Access UI giving its first param the value: "*ABM*"; it works ok and retrieves the 3 records from table Docs where Id_UCAB like "*ABM*". So far so good.

When I invoke this query from VB.Net app using OleDb.OleDbCommand the story changes. If I ommit the value for the first param, and play around with the other 3 it works as expected, but it does not work when given the same "*ABM* value to the first param(it returns no records).

Here is the declaration of the params:
With cmd.Parameters
    .Add(New OleDb.OleDbParameter("@DocId", OleDb.OleDbType.VarChar, 12, Input, 0, 0, Nothing, DataRowVersion.Current, False, Nothing))
    .Add(New OleDb.OleDbParameter("@FechaIni", OleDb.OleDbType.Integer, 4, Input, 10, 0, Nothing, DataRowVersion.Current, False, Nothing))
    .Add(New OleDb.OleDbParameter("@FechaFin", OleDb.OleDbType.Integer, 4, Input, 10, 0, Nothing, DataRowVersion.Current, False, Nothing))
    .Add(New OleDb.OleDbParameter("@OrdCod", OleDb.OleDbType.TinyInt, 2, Input, 10, 0, Nothing, DataRowVersion.Current, False, Nothing))
End With

Here is how I assign the values before calling the Fill method of the Oledb.Oledb.DataAdapter:
With Cmd
            If (DocId <> "") Then
                .Parameters(0).Value = CType(DocId, String)
            Else
                .Parameters(0).Value = Global.System.DBNull.Value
            End If
            If (FechaIni <> "") Then
                .Parameters(1).Value = CType(FechaIni, Integer)
            Else
                .Parameters(1).Value = Global.System.DBNull.Value
            End If
            If (FechaFIn <> "") Then
                .Parameters(2).Value = CType(FechaFIn, Integer)
            Else
                .Parameters(2).Value = Global.System.DBNull.Value
            End If
            If (OrdCod <> "") Then
                .Parameters(3).Value = CType(OrdCod, Byte)
            Else
                .Parameters(3).Value = Global.System.DBNull.Value
            End If
        End With

What I am missing? Confused | :confused:

Thanks for your time and help.

Best Regards.
AnswerRe: VB + OleDb.OleDbCommand + MS Access issue. Pin
dragon_20-Jan-10 2:38
dragon_20-Jan-10 2:38 
GeneralRe: VB + OleDb.OleDbCommand + MS Access issue. Pin
alexvw20-Jan-10 14:12
alexvw20-Jan-10 14:12 
GeneralRe: VB + OleDb.OleDbCommand + MS Access issue. Pin
dragon_20-Jan-10 18:08
dragon_20-Jan-10 18:08 
AnswerSOLVED: VB + OleDb.OleDbCommand + MS Access issue Pin
alexvw30-Jan-10 2:45
alexvw30-Jan-10 2:45 
QuestionHow to change a button background color if i know the name? Pin
spawneditions19-Jan-10 6:36
spawneditions19-Jan-10 6:36 
AnswerRe: How to change a button background color if i know the name? Pin
EliottA19-Jan-10 7:14
EliottA19-Jan-10 7:14 
GeneralRe: How to change a button background color if i know the name? Pin
spawneditions19-Jan-10 7:20
spawneditions19-Jan-10 7:20 
AnswerRe: How to change a button background color if i know the name? Pin
spawneditions19-Jan-10 8:28
spawneditions19-Jan-10 8:28 
GeneralRe: How to change a button background color if i know the name? Pin
dan!sh 19-Jan-10 18:45
professional dan!sh 19-Jan-10 18:45 
QuestionRediming An array object Containing Public Share Variant Pin
A.Najafi19-Jan-10 0:11
A.Najafi19-Jan-10 0:11 
AnswerRe: Rediming An array object Containing Public Share Variant Pin
DaveAuld19-Jan-10 5:17
professionalDaveAuld19-Jan-10 5:17 
QuestionEdit records in vb6 through access Pin
offroaderdan18-Jan-10 22:33
offroaderdan18-Jan-10 22:33 
Questionhow to update a VB .NET application? Pin
jeshra27918-Jan-10 21:48
jeshra27918-Jan-10 21:48 
AnswerRe: how to update a VB .NET application? Pin
Steven J Jowett19-Jan-10 1:14
Steven J Jowett19-Jan-10 1:14 
GeneralRe: how to update a VB .NET application? Pin
jeshra27921-Jan-10 0:30
jeshra27921-Jan-10 0:30 
QuestionI Need Help On Vb.net Smart Devices [modified] Pin
bernard tang18-Jan-10 21:27
bernard tang18-Jan-10 21:27 
AnswerRe: I Need Help On Vb.net Smart Devices Pin
jerryj19-Jan-10 3:31
jerryj19-Jan-10 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.