Ver Mensaje Individual
  #20 (permalink)  
Antiguo 01/03/2005, 10:18
Avatar de Sayra
Sayra
 
Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 19 años, 5 meses
Puntos: 1
Neivan ahora me da un error extraño por que reviso yo lo encuentro bien
la aplicacion se carga selecciono parametros y cuando le doy enviar surge el error

Línea 1: sintaxis incorrecta cerca de 'ANDAgencia'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Línea 1: sintaxis incorrecta cerca de 'ANDAgencia'.

Source Error:
Line 110: MyCommand.Fill(ds, "Agencia")

y bueno finalmente el codigo del boton quedo asi
Sub Button1_Click(sender As Object, e As EventArgs)

Dim s As String = "Elementos seleccionados:<br>"
Dim i As Int32
Dim j As Int32
For i = 0 to Check1.Items.Count-1

If not Check1.Items(i).Selected Then
Iblmessage.Text = "Es necesario que seleccione un servicio"

Else If Check1.Items(i).Selected Then

Dim ds As DataSet
Dim strSql As String
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter

strSql = " SELECT Agencia.Identificador as Agencia, Agencia.Direccion as Direccion, Agencia.Telefono as Telefono, Agencia.Cajero_Automatico as Cajero_Automatico, Agencia.Autobanco as Autobanco, Agencia.Taquilla_Externa as Taquilla_Externa, Agencia.Estacionamiento as Agencia_Estacionamiento, Estado.Nombre_Estado as Estado, Ciudad.Nombre_Ciudad as Ciudad, Ubicacion.Descripcion as Ubicación From Agencia, Estado, Ciudad, Ubicacion "
strSql += " WHERE Agencia.EstadoID=Estado.EstadoID"
strSql += " AND Agencia.CiudadID=Ciudad.CiudadID"
strSql += " AND Agencia.UbicacionID=Ubicacion.UbicacionID"
strSql += " AND Agencia.EstadoID=" &DropDownList1.SelectedItem.Value
strSql += " AND Agencia.CiudadID=" &DropDownList2.SelectedItem.Value
strSql += " AND Agencia.UbicacionID=" &DropDownList3.SelectedItem.Value

For j = 0 To Check1.Items.Count - 1
If Check1.Items(j).Selected Then
' Entra si esta seleccionado
strSql += " AND" & Check1.Items(j).value & "=si"
end if
Next

MyConnection = New SqlConnection("SERVER=MDS01; DATABASE=be; INTEGRATED SECURITY=false;PASSWORD=sa;USER=sa")
MyCommand = New SqlDataAdapter(strSql, MyConnection)

ds = new DataSet()
MyCommand.Fill(ds, "Agencia")

MyDataGrid.DataSource=ds.Tables("Agencia").Default View
MyDataGrid.DataBind()

End If
Next

End Sub