Showing posts with label starts. Show all posts
Showing posts with label starts. Show all posts

Wednesday, March 21, 2012

Problem with simple SQL


I want to view all companyname that starts with A, the sql runs but does not show the output,
What's wrong with the query?, am I missing any quotes or comma. Pls 'elp
Dim myCharacter = "A"
SQL = "SELECTlogo, EmployerID, CompanyName FROM EmployerDetails wherecompanyName like '"&myCharacter & "%'"



Select seems correct! How you are using this in ASP.NET page? Are you getting data into Reader or not?|||Thanks Sreed
I think the problem is the SQL because when I hard code to this
SQL = "SELECT logo, EmployerID, CompanyName FROM EmployerDetails where companyName like 'A%' "
It works, PLS help Thanks
|||

If you declared myCharacter,SQL as a local string variable, then it should work!

Just to debug after SQL = "..blabla" statement do,

Response.Write(SQL)
Response.End()
and run the page and see what is the output you are getting from SQL, and see if that is giving correct Select or not!

That should help us to find whether it building currect SQL or not!

|||Hi Sreed
This is the full code below , I did the PRINT STUFF and the output is also below
Sub BindDataToGrid(myCharacter)
Response.write("Testing "&myCharacter)
Dim Conn, Conn1 as SqlConnection
Dim mySqlCommand, mySqlCommand2 as SqlCommand
Dim SQL,SQL1,SQL2 ,GetQuestions As String
Dim myDate as date
Dim pic as ArrayList = new ArrayList()
Dim Job_no as Integer

IF myCharacter <> "" THEN
SQL ="SELECT logo, EmployerID, CompanyName FROM EmployerDetails where companyName like "
SQL = SQL & " ' " & myCharacter & " % ' "
Else
SQL ="SELECT logo, EmployerID FROM EmployerDetails order by newID() "
End If
Conn = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim resultsDataSet as New DataSet()
Dim myDataAdapter as SqlDataAdapter = New SqlDataAdapter(SQL, Conn)

Conn.Open()
myDataAdapter.Fill(resultsDataSet,"EmployerDetails")
mySqlCommand = New SqlCommand(SQL, Conn)
mySqlCommand.ExecuteNonQuery()

Dim myReader As SqlDataReader = mysqlCommand.ExecuteReader()
Dim content
While myReader.Read()
If not (myReader("Logo") is DBNull.Value) Then
If Len(myReader("Logo")) > 0 Then
Dim LOGO = myReader("Logo")
Dim EmployerID =myReader("EmployerID")
Content = "<br><ahref='/JBoard/EmployerJobs.aspx?EMPID="&EmployerID
Content = Content & " '><img src='/JBoard/CompLogo/"&Logo
Content = Content & " ' width='124' height='50'BORDER='1'></a>"
pic.Add(Content)
End If
End If
End While

LogoGrid.DataSource = pic
LogoGrid.DataBind()
Conn.Close()
End Sub

OUTPUT IS
SELECT logo, EmployerID, CompanyName FROM EmployerDetails where companyName like 'M % '
What is wrong with this tiny code, forum help me pls.


|||

SQL = "SELECT logo, EmployerID, CompanyName FROM EmployerDetails where companyName like "
SQL = SQL &" ' " & myCharacter &" % ' "

This looks like you have extra spaces in there. If you copied and pasted this directly from your code, you're actually querying for anything that starts with a space and then an 'A' and then has a space and then any character and then a space. Drop the spaces in theRED code above and it should work.

|||Hi PD
How do you drop the space, that's why I thought ?

|||Use your keyboard's Delete key to remove the extra spaces around thesingle quote and percentage characters. (A total of 4 spacesshould be deleted.)
That should leave you with the following statement:
SQL = "SELECT logo, EmployerID, CompanyName FROM EmployerDetails where companyName like "
SQL = SQL &"'" & myCharacter &"%' "
|||

tmorton wrote:

Use your keyboard's Delete key to remove the extra spaces


In a recent technical journal, it suggested that the Backspace key canalso be used to remove characters. I haven't tried it myself, as I fearthat I'm not advanced enough. But obinna123 seems pretty advanced, sohe may want to try that technique to removed the extra spaces.

Problem with Service Principle Name after new install

Hi all,
I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
service under a domain user account.
When the SQL Server starts, I find a warning in the event log:
Source: MSSQLServer EventID: 19011
Description: SuperSocket info: (SpnRegister) : Error 8344.
After reading several KB articles I understand that the service account
tries to register the Service Principle Name on startup and fails because it
does not have the rights the register the SPN in Active Directory.
I put the account in the local admin group on the server and created a SPN
with setspn.exe from Win2000 resource kit, which points to at the domain
account. Does not fix the warning message.
I do not want to put the account into domain admin group, which would fix
the problem I think, because domain admins have all permissions to register
the SPN.
Does someone have a hint for me?
Thanks in advance
Regards
Christian
If your server should always work using same tcp port, you may ignore this
message.
If server works under LocalSystem or other account which has such
permissions (by default - only Domain Admins), he registers SPN at startup
and unregisters at shutdown. So in your case if you change tcp/ip settings
for server, you will have to reregister SPN manually. Or you may give such
rights to service account - see this article for permissions info:
http://technet2.microsoft.com/Window...e47441033.mspx
WBR, Evergray
Words mean nothing...
"Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
> service under a domain user account.
> When the SQL Server starts, I find a warning in the event log:
> Source: MSSQLServer EventID: 19011
> Description: SuperSocket info: (SpnRegister) : Error 8344.
> After reading several KB articles I understand that the service account
> tries to register the Service Principle Name on startup and fails because
> it does not have the rights the register the SPN in Active Directory.
> I put the account in the local admin group on the server and created a SPN
> with setspn.exe from Win2000 resource kit, which points to at the domain
> account. Does not fix the warning message.
> I do not want to put the account into domain admin group, which would fix
> the problem I think, because domain admins have all permissions to
> register the SPN.
> Does someone have a hint for me?
> Thanks in advance
> Regards
> Christian
>
|||Thanks for reply,
at least you pointed us in the right direction.
I read the article, but again MS describes not which rights an account needs
in order to register the SPN at startup. All information you get is, that it
works with domain admin rights and with local system.
Nonetheless, the information, that a special function is executed in Active
Directory let us search through the Advanced Active Directory permission
settings and we found that giving the permission to "write public
information" to the SQL Service Account solves the problem.
This prevents us from assigning domain admin rights.
Strange, that Microsoft does not point out which specific permissions have
to be set for a normal user account, but in the other tells you to not use a
admin account.
Anyway this is solved for us.
Regards
Christian
"Oleksandr Chuchko" <forlists@.mail.ru> schrieb im Newsbeitrag
news:%23JIEvO5RGHA.5036@.TK2MSFTNGP12.phx.gbl...
> If your server should always work using same tcp port, you may ignore this
> message.
> If server works under LocalSystem or other account which has such
> permissions (by default - only Domain Admins), he registers SPN at startup
> and unregisters at shutdown. So in your case if you change tcp/ip settings
> for server, you will have to reregister SPN manually. Or you may give such
> rights to service account - see this article for permissions info:
> http://technet2.microsoft.com/Window...e47441033.mspx
> --
> WBR, Evergray
> --
> Words mean nothing...
>
> "Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
> news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
>

Problem with Service Principle Name after new install

Hi all,
I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
service under a domain user account.
When the SQL Server starts, I find a warning in the event log:
Source: MSSQLServer EventID: 19011
Description: SuperSocket info: (SpnRegister) : Error 8344.
After reading several KB articles I understand that the service account
tries to register the Service Principle Name on startup and fails because it
does not have the rights the register the SPN in Active Directory.
I put the account in the local admin group on the server and created a SPN
with setspn.exe from Win2000 resource kit, which points to at the domain
account. Does not fix the warning message.
I do not want to put the account into domain admin group, which would fix
the problem I think, because domain admins have all permissions to register
the SPN.
Does someone have a hint for me?
Thanks in advance
Regards
ChristianIf your server should always work using same tcp port, you may ignore this
message.
If server works under LocalSystem or other account which has such
permissions (by default - only Domain Admins), he registers SPN at startup
and unregisters at shutdown. So in your case if you change tcp/ip settings
for server, you will have to reregister SPN manually. Or you may give such
rights to service account - see this article for permissions info:
http://technet2.microsoft.com/Windo...de47441033.mspx
WBR, Evergray
--
Words mean nothing...
"Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
> service under a domain user account.
> When the SQL Server starts, I find a warning in the event log:
> Source: MSSQLServer EventID: 19011
> Description: SuperSocket info: (SpnRegister) : Error 8344.
> After reading several KB articles I understand that the service account
> tries to register the Service Principle Name on startup and fails because
> it does not have the rights the register the SPN in Active Directory.
> I put the account in the local admin group on the server and created a SPN
> with setspn.exe from Win2000 resource kit, which points to at the domain
> account. Does not fix the warning message.
> I do not want to put the account into domain admin group, which would fix
> the problem I think, because domain admins have all permissions to
> register the SPN.
> Does someone have a hint for me?
> Thanks in advance
> Regards
> Christian
>|||Thanks for reply,
at least you pointed us in the right direction.
I read the article, but again MS describes not which rights an account needs
in order to register the SPN at startup. All information you get is, that it
works with domain admin rights and with local system.
Nonetheless, the information, that a special function is executed in Active
Directory let us search through the Advanced Active Directory permission
settings and we found that giving the permission to "write public
information" to the SQL Service Account solves the problem.
This prevents us from assigning domain admin rights.
Strange, that Microsoft does not point out which specific permissions have
to be set for a normal user account, but in the other tells you to not use a
admin account.
Anyway this is solved for us.
Regards
Christian
"Oleksandr Chuchko" <forlists@.mail.ru> schrieb im Newsbeitrag
news:%23JIEvO5RGHA.5036@.TK2MSFTNGP12.phx.gbl...
> If your server should always work using same tcp port, you may ignore this
> message.
> If server works under LocalSystem or other account which has such
> permissions (by default - only Domain Admins), he registers SPN at startup
> and unregisters at shutdown. So in your case if you change tcp/ip settings
> for server, you will have to reregister SPN manually. Or you may give such
> rights to service account - see this article for permissions info:
> http://technet2.microsoft.com/Windo...de47441033.mspx
> --
> WBR, Evergray
> --
> Words mean nothing...
>
> "Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
> news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
>sql

Problem with Service Principle Name after new install

Hi all,
I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
service under a domain user account.
When the SQL Server starts, I find a warning in the event log:
Source: MSSQLServer EventID: 19011
Description: SuperSocket info: (SpnRegister) : Error 8344.
After reading several KB articles I understand that the service account
tries to register the Service Principle Name on startup and fails because it
does not have the rights the register the SPN in Active Directory.
I put the account in the local admin group on the server and created a SPN
with setspn.exe from Win2000 resource kit, which points to at the domain
account. Does not fix the warning message.
I do not want to put the account into domain admin group, which would fix
the problem I think, because domain admins have all permissions to register
the SPN.
Does someone have a hint for me?
Thanks in advance
Regards
ChristianIf your server should always work using same tcp port, you may ignore this
message.
If server works under LocalSystem or other account which has such
permissions (by default - only Domain Admins), he registers SPN at startup
and unregisters at shutdown. So in your case if you change tcp/ip settings
for server, you will have to reregister SPN manually. Or you may give such
rights to service account - see this article for permissions info:
http://technet2.microsoft.com/WindowsServer/en/Library/8127f5ed-4e05-4822-bfa9-402ceede47441033.mspx
--
WBR, Evergray
--
Words mean nothing...
"Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I installed a SQL Server 2000 on a Win2003 machine, running the SQL Server
> service under a domain user account.
> When the SQL Server starts, I find a warning in the event log:
> Source: MSSQLServer EventID: 19011
> Description: SuperSocket info: (SpnRegister) : Error 8344.
> After reading several KB articles I understand that the service account
> tries to register the Service Principle Name on startup and fails because
> it does not have the rights the register the SPN in Active Directory.
> I put the account in the local admin group on the server and created a SPN
> with setspn.exe from Win2000 resource kit, which points to at the domain
> account. Does not fix the warning message.
> I do not want to put the account into domain admin group, which would fix
> the problem I think, because domain admins have all permissions to
> register the SPN.
> Does someone have a hint for me?
> Thanks in advance
> Regards
> Christian
>|||Thanks for reply,
at least you pointed us in the right direction. :)
I read the article, but again MS describes not which rights an account needs
in order to register the SPN at startup. All information you get is, that it
works with domain admin rights and with local system.
Nonetheless, the information, that a special function is executed in Active
Directory let us search through the Advanced Active Directory permission
settings and we found that giving the permission to "write public
information" to the SQL Service Account solves the problem.
This prevents us from assigning domain admin rights.
Strange, that Microsoft does not point out which specific permissions have
to be set for a normal user account, but in the other tells you to not use a
admin account.
Anyway this is solved for us.
Regards
Christian
"Oleksandr Chuchko" <forlists@.mail.ru> schrieb im Newsbeitrag
news:%23JIEvO5RGHA.5036@.TK2MSFTNGP12.phx.gbl...
> If your server should always work using same tcp port, you may ignore this
> message.
> If server works under LocalSystem or other account which has such
> permissions (by default - only Domain Admins), he registers SPN at startup
> and unregisters at shutdown. So in your case if you change tcp/ip settings
> for server, you will have to reregister SPN manually. Or you may give such
> rights to service account - see this article for permissions info:
> http://technet2.microsoft.com/WindowsServer/en/Library/8127f5ed-4e05-4822-bfa9-402ceede47441033.mspx
> --
> WBR, Evergray
> --
> Words mean nothing...
>
> "Christian Guntsche" <christian.guntsche@.docuware.com> wrote in message
> news:OxLkQH1RGHA.1688@.TK2MSFTNGP11.phx.gbl...
>> Hi all,
>> I installed a SQL Server 2000 on a Win2003 machine, running the SQL
>> Server service under a domain user account.
>> When the SQL Server starts, I find a warning in the event log:
>> Source: MSSQLServer EventID: 19011
>> Description: SuperSocket info: (SpnRegister) : Error 8344.
>> After reading several KB articles I understand that the service account
>> tries to register the Service Principle Name on startup and fails because
>> it does not have the rights the register the SPN in Active Directory.
>> I put the account in the local admin group on the server and created a
>> SPN with setspn.exe from Win2000 resource kit, which points to at the
>> domain account. Does not fix the warning message.
>> I do not want to put the account into domain admin group, which would fix
>> the problem I think, because domain admins have all permissions to
>> register the SPN.
>> Does someone have a hint for me?
>> Thanks in advance
>> Regards
>> Christian
>