ibm midrange - AS400 SQL query with Parameter -


I'm testing a simple query to get data from an AS400 database I'm not sure The way I am using SQL queries is correct.

I get an error: "The parameter is incorrect."

  FIELD1, MyLibrary.MyTable WHERE FIELD1 = @ field1 from FIELD2  

When I run the following query, I get no error:

  Select FIELD1, FIELD2 from MyLibrary.MyTable where FIELD1 = 'myvalue'  

I am using ADODB, VBScript to test .

  Set Param1 = cmd.CreateParameter ("Field 1", 129, 1, 9, "MyView") '12 9 string CMD.Pamatrets.Paper1  < / Pre> 

I am coming from MS SQL environment, so the writing for AS 400 is completely new to me. Thank you

OK, I've got the solution and trying for different things.

As I said earlier, let me OLEDB and ADO Used for the Net, so I used to work this way:

  Select FIELD1, FIELD2 from MyLibrary. MyTable WHERE FIELD1 = @ field1  

which is not in AS / 400 in the WooRac in Access and SQL Server.

I found the following to work:

  Choose FIELD1, FIELD2 from MyLibrary.What's the table WHERE FIELD1 =? Cmd.ActiveConnection = connstr cmd.CommandType = 1'4 'stored procedure' 1 text cmd.CommandText = sql Param1 = cmd.CreateParameter ("@field1", 129, 1, 9, "myvalue") '12 9 string CMD. Parameters.Append Param1 set rs = cmd.Execute ()  

All this is VbScript. The couple had to add a question mark (?) To the SQL statement.


Comments