VB 6.0 - Runtime error 3001 - Asked By Efrem Dawit on 07-Jul-05 05:34 AM

Hi, 

I have another problem with ADO vb 6 

The problem is I try to connect the Ms Access Database using ADO. 
The code I use is 

when I reach rsqt.Open sqlqt, 1, 2 it says 
Runtime error 3001 - Arguments are of the wrong type, are out of acceptble range or are in conflict with one another. 

When I use the SQl in MS access, it works fine. What is the problem from the following code. 


Private Sub Qrtbrkdown_Click() 
Dim qrt1, bud As String 
Dim k, amt As Integer 
Dim rs, rs1, rsq1, rsq2t, rsqit1, rsqt As New ADODB.Recordset 
Dim sqlqt, sqlq2t, sqlqit, sqlqit1 As String 

Quarter.Visible = True 
qrt1 = InputBox("Which year do you want allocate quarterly?", "Year") 

Label7.Caption = qrt1 ' Year 

Set conn = New ADODB.Connection 
conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False") 
Set rsqt = CreateObject("adodb.recordset") 


conn.BeginTrans 
   sqlqt = "select amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'" 
   conn.Execute sqlqt 
   rsqt.Open sqlqt, 1, 2 

conn.CommitTrans 


Label9.Caption = 200 ' Annual Budget 

Set rsq2t = CreateObject("adodb.recordset") 

    conn.BeginTrans 
        sqlq2t = "select budallid, amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'" 
        rsq2t.Open sqlq2t, 1, 2 
    conn.CommitTrans 

bud = rsq2t.Fields(0) 

For k = 1 To 4 
qurtamt(k) = InputBox("Amount for Quarter " & k & ",", "Quarter") 
Next k 

conn.BeginTrans 
sqlqit = "insert into temp_Qur_Bud(budallid,quarter,amount) values('" & bud & "','" & qur(k) & "'," & qurtamt(k) & ")" 
rsqt.Open sqlqit, 1, 2 

conn.CommitTrans 

sqlqit1 = "select * from temp_ann where prjid = '" & prjNo.Text & "'" 
rsqt.Open sqlqit1, conn, 1, 2 

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False" 
Adodc1.CommandType = adCmdText 
Adodc1.RecordSource = sqlqit1 
Adodc1.Refresh 
Set budgetbrk.DataSource = Adodc1 
qrtbudget.Visible = True 
rsqt.close 

End Sub 

Thank u

VB Resultset Error - Asked By Rohan Bairat on 07-Jul-05 10:29 AM

try

set rsqt  = conn.execute(sqlqt )

instead

What is the value of the sql string? - Asked By Robbe Morris on 07-Jul-05 10:46 AM

Also, why are you using BeginTrans and CommitTrans with SELECT statements?

If you are using Visual Basic 6, you should using the ADO constants and not these numbers.

Are you sure you need ' around the values in your sql?  If the data types for those columns are numbers, floats, or other non-string data type, you shouldn't use single quotes around the values.