In Visual Basic .net we have the modules to write public functions and routines in order to call them from several points of entire application.
What about c# 2019? Modules don't exist in C#. Any suggestions please? Thank you so much in advanced.
Example of a public void function, I have several of them, that I need to call them.
What about c# 2019? Modules don't exist in C#. Any suggestions please? Thank you so much in advanced.
Example of a public void function, I have several of them, that I need to call them.
Code:
public void Search(string sql, SqlConnection con)
{
if (con.State == ConnectionState.Closed)
con.Open();
SqlCommand Cmd = new SqlCommand(sql, con);
Cmd.CommandType = CommandType.Text;
SqlDataReader Rdr = Cmd.ExecuteReader();
if (Rdr.HasRows == false)
MessageBox.Show("H εγγραφή που αναζητάτε δεν υπάρχει! ", "Αναζήτηση ");
while (Rdr.HasRows)
{
while (Rdr.Read())
{
foreach (Control cntl in this.Controls)
{
if (cntl.GetType() == typeof(TextBox))
for (int i = 0; i <= Rdr.FieldCount - 1; i++)
if (cntl.Name.Equals(Rdr.GetName(i)))
cntl.Text = Rdr.GetString(i);
}
}
Rdr.NextResult();
}
saveSqlQ.SQL = sql;
}