i have a django code that connect to sql server database and i am trying to 
select values using *like *but once i try it it crash and the system 
display the below error:

('The SQL contains 0 parameter markers, but 1 parameters were supplied', 
'HY000')


views.py

========


from django.shortcuts import render
import pyodbc
# from .models import Artist
# Create your views here.


def connect(request):
 
    conn = pyodbc.connect(
        'Driver={ODBC Driver 17 for SQL Server};'
        'Server=DESKTOP-LPD1575\\SQLEXPRESS;'
        'Database=testDB;'
        'UID=test;'
        'PWD=*****;'

    )
    query = 'jhon'
    cursor = conn.cursor()
 
    c = cursor.execute('SELECT * FROM Artist where artistName like "%?%"',query)
    print(c)
    return render (request,'connect.html',{"c":c})



connect.html
==========
<table align = "center">
<tr align="center">
            <th>id</th>
            <th>FolderNumber</th>
            <th>Folderdate</th>
           
        </tr>
{% for row in c %}
 <tr align="center">
    <td>{{ row.0 }}</td>
    <td>{{ row.1 }}</td>
    <td>{{ row.2 }}</td>
    
</tr>
{% endfor %}
</table>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/485f0fc0-c340-460c-aef3-00177c8a2ef7%40googlegroups.com.

Reply via email to