Forum Discussion

nadim96's avatar
New Member
2 years ago

ADO connection to delete record

I have MS SQL Server and using python for TC scripting.
my query to select and retreve data from the DB works fine. the problem is with the below script for deleting a record.
I have the required DB permissions and the query works fine from MS SQL. the DB connection work fine as well.

def TestSQL_ADO():
Qry = ADO.CreateADOQuery();
Qry.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=ConnectDB; Server =; Database=myDB;user id =nadim;password=****"
Qry.SQL = "Delete From Login.User Where User_Login_Name = 'NADIM1'"


1 Reply

  • Kitt's avatar
    Regular Contributor

    Is the name of your database "Login.User"? You may want to wrap your db objects in [], like this:

    Qry.SQL = "Delete From [Login.User] Where [User_Login_Name] = 'NADIM1'"


    If "Login" is the name of your database then you can either remove it and just reference the "User" table OR add the ".dbo." identifier between the db and table names, like this:

    Qry.SQL = "Delete From Login.dbo.User Where User_Login_Name = 'NADIM1'"