"el valor no esta dentro del intervalo esperado - No se controló System.ArgumentException"
en esta parte del codigo: en la linea de color rojo
Código vb:
Ver original
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click frm = New Form2 Form2.ShowDialog() ' en esta linea me indica el error End Sub (con este codigo voy al formulario 2)
El codigo de mi Formulario 1 es este:
Código vb:
Ver original
Imports System Imports System.Data Imports System.Data.SqlClient Public Class Form1 Dim cnn As New SqlConnection("data source = servidor; initial catalog = base; user id = user; password = pass") Dim Ada As New SqlDataAdapter() '' Dim Ds As New DataSet() Dim frm As Form2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'cnn.Open() 'MessageBox.Show("Se Conecto con exito a la Base de datos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information) 'cnn.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Sqlstr As New SqlCommand("SELECT NOMBRE, DIRECCION,LOCALIDAD FROM CLIENTES WHERE CODIGO=" & "'" & TextBox1.Text & "'", cnn) cnn.Open() Dim dr As SqlDataReader = Sqlstr.ExecuteReader(CommandBehavior.CloseConnection) While dr.Read Dim value As Object = dr.Item("NOMBRE") If value IsNot DBNull.Value Then TextBox2.Text = CStr(value) value = dr.Item("DIRECCION") If value IsNot DBNull.Value Then TextBox3.Text = CStr(value) value = dr.Item("LOCALIDAD") If value IsNot DBNull.Value Then TextBox4.Text = CStr(value) End While dr.Close() 'cnn.Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click frm = New Form2 Form2.ShowDialog() ' (con este codigo voy al formulario 2) End Sub End Class
Este es el Codigo de MI formulario 2
Código vb:
Ver original
Public Class Form2 Dim frm2 As Form1 Private Sub Med_Terreno_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Med_Terreno.Click End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click frm2 = New Form1 Me.Close() Form1.ShowDialog() ' (con este codigo vuelvo al formulario 1) End Sub End Class
Me podrian ayudar a solucionar este error por favor...