Carlos kambui

Carlos kambui

  • NA
  • 499
  • 124.5k

Converting the Codes from C# to Java

Mar 5 2018 12:45 AM
i want to Convert the below codes in c# to java but i got an error for Dasatet declaration
 
private DataSet ds = new DataSet();
private SqlDataAdapter dbAdapter = new SqlDataAdapter();
public usertype Getuser(int sCode)
{
usertype tuser = new usertype();
BuildConnstring();
using (SqlConnection conn = new SqlConnection(connstring))
{
using (SqlCommand Command = conn.CreateCommand())
{
conn.Open();
Command.CommandText = "select * from sys_user where user_id='" + sCode + "'";
Command.CommandType = CommandType.Text;
dbAdapter.SelectCommand = Command;
ds.Clear();
ds.DataSetName = "User";
dbAdapter.Fill(ds);
}
}
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
tuser = new usertype();
tuser.staff_id = Convert.ToInt32(ds.Tables[0].Rows[i]["staff_id"]);
tuser.user_id = Convert.ToInt32(ds.Tables[0].Rows[i]["user_id"]);
tuser.User_name = ds.Tables[0].Rows[i]["User_name"].ToString();
tuser.user_pin = ds.Tables[0].Rows[i]["user_pin"].ToString();
tuser.staff_sir_name = ds.Tables[0].Rows[i]["staff_sir_name"].ToString();
}
}
}
else
{
tuser = new usertype();
tuser.user_id = 0;
}
return tuser;
}
 
kindly help to convert will highly appreciate

Answers (1)