busqueda con campos NULL

07/08/2004 - 01:25 por Enrique Rodríguez | Informe spam
Hola Foro.
A ver si alguien me puede orientar un poco.
Tengo una busqueda construida por un SELECT que esta dentro de la funcion
que aparece aqui abajo, el detalle es que ahora solo me muestra los
registros que no tengan valores NULL dentro de los campos "CStandar1" y
"CStandar2", se que con ".ToString()" puedo solucionar eso, pero no se en
que parte de mi codigo debo ponerlo, a ver si alguno de ustedes puede
orientarme de favor.

Saludos y Gracias.

Enrique Rodriguez
************************************************************
Function BuscarCruce(ByVal cruce As String, ByVal cStandar1 As String,
ByVal cStandar2 As String, ByVal zona As String, ByVal nodo As String, ByVal
municipio As String, ByVal tipoCruce As String) As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\Inetpub\wwwr"& _
"oot\cruces\cruces.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [cruces].[ID], [cruces].[Cruce],
[cruces].[CSistema1], [cruces].[CSistema2"& _
"], [cruces].[Zona], [cruces].[Nodo], [cruces].[Municipio],
[cruces].[TipoCruce] "& _
"FROM [cruces] WHERE (([cruces].[Cruce] like @Cruce+'%') AND
([cruces].[CStandar1] li"& _
"ke @CStandar1+'%') AND ([cruces].[CStandar2] like @CStandar2+'%') AND
([cruces].[Zona] l"& _
"ike @Zona+'%') AND ([cruces].[Nodo] like @Nodo+'%') AND
([cruces].[Municipio] like @Muni"& _
"cipio+'%') AND ([cruces].[TipoCruce] like @TipoCruce+'%'))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_cruce As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cruce.ParameterName = "@Cruce"
dbParam_cruce.Value = cruce
dbParam_cruce.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cruce)
Dim dbParam_cStandar1 As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cStandar1.ParameterName = "@CStandar1"
dbParam_cStandar1.Value = cStandar1
dbParam_cStandar1.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cStandar1)
Dim dbParam_cStandar2 As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cStandar2.ParameterName = "@CStandar2"
dbParam_cStandar2.Value = cStandar2
dbParam_cStandar2.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cStandar2)
Dim dbParam_zona As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_zona.ParameterName = "@Zona"
dbParam_zona.Value = zona
dbParam_zona.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_zona)
Dim dbParam_nodo As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_nodo.ParameterName = "@Nodo"
dbParam_nodo.Value = nodo
dbParam_nodo.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_nodo)
Dim dbParam_municipio As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_municipio.ParameterName = "@Municipio"
dbParam_municipio.Value = municipio
dbParam_municipio.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_municipio)
Dim dbParam_tipoCruce As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_tipoCruce.ParameterName = "@TipoCruce"
dbParam_tipoCruce.Value = tipoCruce
dbParam_tipoCruce.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_tipoCruce)

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function
***************************************************************
 

Leer las respuestas

#1 Franco Figún
07/08/2004 - 21:07 | Informe spam
Si mal no me equivoco, lo podes manejar asi:

if (strData!ÛNull.Value.ToString())

y despues haces tu rutina.

Este link te puede dar una idea:

http://www.c-sharpcorner.com/Code/2...ontrol.asp

FF
www.francofigun.com.ar
www.microsofties.com.ar
Yahoo MSN:

"Enrique Rodríguez" wrote in message
news:#
Hola Foro.
A ver si alguien me puede orientar un poco.
Tengo una busqueda construida por un SELECT que esta dentro de la funcion
que aparece aqui abajo, el detalle es que ahora solo me muestra los
registros que no tengan valores NULL dentro de los campos "CStandar1" y
"CStandar2", se que con ".ToString()" puedo solucionar eso, pero no se en
que parte de mi codigo debo ponerlo, a ver si alguno de ustedes puede
orientarme de favor.

Saludos y Gracias.

Enrique Rodriguez
************************************************************
Function BuscarCruce(ByVal cruce As String, ByVal cStandar1 As String,
ByVal cStandar2 As String, ByVal zona As String, ByVal nodo As String,


ByVal
municipio As String, ByVal tipoCruce As String) As System.Data.DataSet
Dim connectionString As String "Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\Inetpub\wwwr"& _
"oot\cruces\cruces.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [cruces].[ID],


[cruces].[Cruce],
[cruces].[CSistema1], [cruces].[CSistema2"& _
"], [cruces].[Zona], [cruces].[Nodo], [cruces].[Municipio],
[cruces].[TipoCruce] "& _
"FROM [cruces] WHERE (([cruces].[Cruce] like @Cruce+'%') AND
([cruces].[CStandar1] li"& _
"ke @CStandar1+'%') AND ([cruces].[CStandar2] like @CStandar2+'%') AND
([cruces].[Zona] l"& _
"ike @Zona+'%') AND ([cruces].[Nodo] like @Nodo+'%') AND
([cruces].[Municipio] like @Muni"& _
"cipio+'%') AND ([cruces].[TipoCruce] like @TipoCruce+'%'))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_cruce As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cruce.ParameterName = "@Cruce"
dbParam_cruce.Value = cruce
dbParam_cruce.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cruce)
Dim dbParam_cStandar1 As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cStandar1.ParameterName = "@CStandar1"
dbParam_cStandar1.Value = cStandar1
dbParam_cStandar1.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cStandar1)
Dim dbParam_cStandar2 As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_cStandar2.ParameterName = "@CStandar2"
dbParam_cStandar2.Value = cStandar2
dbParam_cStandar2.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_cStandar2)
Dim dbParam_zona As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_zona.ParameterName = "@Zona"
dbParam_zona.Value = zona
dbParam_zona.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_zona)
Dim dbParam_nodo As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_nodo.ParameterName = "@Nodo"
dbParam_nodo.Value = nodo
dbParam_nodo.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_nodo)
Dim dbParam_municipio As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_municipio.ParameterName = "@Municipio"
dbParam_municipio.Value = municipio
dbParam_municipio.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_municipio)
Dim dbParam_tipoCruce As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_tipoCruce.ParameterName = "@TipoCruce"
dbParam_tipoCruce.Value = tipoCruce
dbParam_tipoCruce.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_tipoCruce)

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function
***************************************************************


Preguntas similares