Highlighted
Contributor.
Contributor.
1205 views

MySqlParameter

Jump to solution

How would you write this in .net Cobol as an object initializer.

 

SqlParameter[] parameters =
{    
  new SqlParameter("@first_name", SqlDbType.VarChar, 50) { Value = to.FirstName },
  new SqlParameter("@last_name", SqlDbType.VarChar, 50) { Value = to.LastName },
  new SqlParameter("@middle_name", SqlDbType.VarChar, 50) { Value = to.MiddleName },
  new SqlParameter("@empid", SqlDbType.Int) { Value = to.EmpId }
};

I have so far

method-id LogUserInfo(tro as type TO_Queue) public.
local-storage section.
01 parms type MySqlParameter occurs any.

set parms = new MySqlParameter("@username", tro::UserName)

Where do i take it from here to declare an object initializer?
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: MySqlParameter

Jump to solution
Something like this should do the trick I think:

declare parms = table of
(
new SqlParameter("@first_name", type SqlDbType::VarChar, 50,
property Value = cust::FirstName)
new SqlParameter("@last_name", type SqlDbType::VarChar, 50,
property Value = cust::LastName)
)

View solution in original post

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: MySqlParameter

Jump to solution
Something like this should do the trick I think:

declare parms = table of
(
new SqlParameter("@first_name", type SqlDbType::VarChar, 50,
property Value = cust::FirstName)
new SqlParameter("@last_name", type SqlDbType::VarChar, 50,
property Value = cust::LastName)
)

View solution in original post

0 Likes
Highlighted
Contributor.
Contributor.

RE: MySqlParameter

Jump to solution
Can you declare the table in the local storage section? Say for example 01 parms table occurs any. And then write set parms = ( )
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: MySqlParameter

Jump to solution
Yes, that should be absolutely fine.
0 Likes
Highlighted
Contributor.
Contributor.

RE: MySqlParameter

Jump to solution
method-id GetUserInfo (tro as type TO_Queue) returning valid as type Boolean static
local-storage section.
01 dict type Dictionary[string, string] value new Type Dictionary[string, string].
01 parms table occurs any.

set parms = (
new MySqlParameter("username", tro::UserName)
new MySqlParameter("password", type GlobalMethods::Decrypt(tro::Password)::Trim())
)

I am getting unknown data description qualifier at 01 parms table occurs any.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: MySqlParameter

Jump to solution
Ah no, sorry, you need to have:
01 parms type MySqlParameter occurs any.
and set parms = table of (...)
0 Likes
Highlighted
Contributor.
Contributor.

RE: MySqlParameter

Jump to solution
Thanks Robert! I am teaching myself .net cobol coming from C# and VB.Net so the syntax is still fairly new. I learned COBOL back in the 80's so the .net Cobol is great and I love it better that the old COBOL, but it is still challenging.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.