Перевести код с C# - Visual Basic .NET
Формулировка задачи:
Здравствуйте! Пишу программуи не могу разобраться как переделать этот код под Visual Basic
Я конечно понимаю,что они похожи,но все же.
Листинг программы
- private void button2_Click(object sender, EventArgs e)
- {
- int count = 0;
- using (SqlConnection connection = new SqlConnection(@"Data Source=prodenis\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db_APM.mdf;Integrated Security=True;user Instance=True"))
- using (SqlCommand command = new SqlCommand("select * from [user] where user=user and password=password", connection))
- {
- command.Parameters.AddWithValue("user", textBox1.Text);
- command.Parameters.AddWithValue("password", textBox2.Text);
- connection.Open();
- using (SqlDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- count += 1;
- }
- connection.Close();
- }
- if (count == 0)
- {
- MessageBox.Show("Пароль неверен!");
- return;
- }
- this.Hide();
- APM frm2 = new APM();
- frm2.Show();
- }
- }
- }
Решение задачи: «Перевести код с C#»
textual
Листинг программы
- Private Sub button2_Click(sender As Object, e As EventArgs)
- Dim count As Integer = 0
- Using connection As New SqlConnection("Data Source=prodenis\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db_APM.mdf;Integrated Security=True;user Instance=True")
- Using command As New SqlCommand("select * from [user] where user=user and password=password", connection)
- command.Parameters.AddWithValue("user", textBox1.Text)
- command.Parameters.AddWithValue("password", textBox2.Text)
- connection.Open()
- Using reader As SqlDataReader = command.ExecuteReader()
- While reader.Read()
- count += 1
- End While
- End Using
- connection.Close()
- End Using
- If count = 0 Then
- MessageBox.Show("Пароль неверен!")
- Return
- End If
- Me.Hide()
- Dim frm2 As New APM()
- frm2.Show()
- End Using
- End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д