Connection to SQL VB.net

1

On a simple page in VB ASP.NET I get an error with the SQL connection:

  

The multi-step operation of OLE DB generated errors. Check the OLE DB status values if possible. No work was done.

I am new in the VB language, I leave a sample of my code

 <%@ Page  aspcompat=true Language="vb" AutoEventWireup="false" CodeBehind="buscar.aspx.vb" Inherits="buscador_yuyin.WebForm1" %>

                Seeker                     

Results obtained with <% = Request ("Word")% >

<% 
    Dim Conexion, Tabla

    Conexion = Server.CreateObject("adodb.connection")
    Tabla = Server.CreateObject("adodb.recordset")
    Conexion.ConnectionString = "PROVIDER=SQLOLEDB;Data Source=TEST-PC\VIRTUAL;DATABASE=prueba;Integrated Security=True"
    Conexion.open()

    Dim Temp
    Temp = "Select * From busqueda('" & Request("palabra") & ")'"

    Tabla.Open(Temp, Conexion)

    If Tabla.BOF And Tabla.EOF Then
%> 
    <p><font face="Tahoma" size="2">No se ha encontrado nada con <strong><%=Request("palabra")%></strong> en la Base de Datos</font></p> 

<% 
    Else
%> 
   <div align="center"><center> 
   <table border="1" cellpadding="0" cellspacing="0" width="100%" height="74" bordercolor="#C0C0C0"> 
   <tr> 
       <td width="28%" height="19"> 
       <p align="center"><strong><font face="Tahoma" size="2">Categoria</font></strong> 
    </td> 
    <td width="28%" height="19"> 
       <p align="center"><strong><font face="Tahoma" size="2">Producto</font></strong></p> 
    </td> 
    <td width="52%" height="19"> 
       <p align="center"><strong><font face="Tahoma" size="2">Descripcion</font></strong> 
    </td> 
    <td width="19%" height="19"> 
       <p align="center"><strong><font face="Tahoma" size="2">Url</font></strong></p> 
    </td> 
   </tr> 
   <% While Not Tabla.EOF%> 
      <tr> 
       <td width="28%" bgcolor="#FFCC00" height="51"> 
          <p align="center"><font face="Tahoma" size="2"><%=Tabla.Fields("Categoria")%></font></td> 
       <td width="28%" bgcolor="#FFCC00" height="51"> 
          <p align="center"><font face="Tahoma" size="2"><%=Tabla.Fields("Nombre")%></font></td> 
       <td width="52%" bgcolor="#FFCC00" height="51"> 
          <p align="center"><font face="Tahoma" size="2"><%=Tabla.Fields("Descripcion")%></font></td> 
       <td width="19%" bgcolor="#FFCC00" height="51"> 
          <p align="center"><a href="<%=Tabla.Fields("url")%>"><font face="Tahoma" size="2">Img</font></a> 
      </tr> 
<% 
            Tabla.MoveNext
        End While
        Tabla.Close
        Conexion.Close
    End If
%> 
</table> 
</center></div> 
<p align="center"><font face="Tahoma" size="2">Busquedas</font></p> 
<p align="center"><font face="Tahoma" size="2">2002</font></p> 
<p align="center"> </p> 
</body> 

    
asked by German AT 19.12.2016 в 03:46
source

2 answers

1

I'm not sure, but it seems you have a detail in this line:

Temp = "Select * From busqueda('" & Request("palabra") & ")'"

applying the correction:

Temp = "Select * From busqueda('" & Request("palabra") & "')"

I do not know if that quote would affect you, how would the string final% be?

Select * from busquedas('palabra')

Are you calling a function? or why is it this way ?, because if you are using SQL, it should be something like:

Select * from tabla where campo like '%texto_a_buscar%'

In your case, I do not know what the name of the field but assuming that it is called a word:

Temp = "Select * From busqueda where palabra like '%" & Request("palabra") & "%'"

I add that according to the error:

It can be because the connection or the query has some detail, it can be incongruence between the different types of data, etc., first validate what I say, if you have the code example to share, some .zip or .rar could help you better. Greetings.

    
answered by 20.12.2016 / 01:31
source
0

It is as Cristina indicates, the error is in your query:

Temp = "Select * From busqueda('" & Request("palabra") & ")'"

It should be:

Temp = "Select * From Tabla Where campo = '" & Request("palabra") & "' "

O:

Temp = "Select * From Tabla Where campo Like '%" & Request("palabra") & "%' "
    
answered by 27.02.2017 в 17:55