Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.Data.SqlClient.SqlException: Incorrect syntax near ')'.
Source Error:
Line 42: objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)
Line 43: ' Fill the dataset.
Line 44: objAdapter.Fill(objDataset)
Line 45: ' Create a new view.
Line 46: Dim oView As New DataView(objDataset.Tables(0))
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim AllorOne As String Dim company As String AllorOne = Request.QueryString("AllorOne") company = Request.QueryString("company")' Create a connection and open it. Dim objConn As New System.Data.SqlClient.SqlConnection("User ID=******;Password=******;Initial Catalog=customer_config;Data Source=rqa4-sql01;") objConn.Open() Dim strSQL As String Dim objDataset As New DataSet() Dim objAdapter As New System.Data.SqlClient.SqlDataAdapter() ' Get all the sql If AllorOne ="All" Then strSQL ="SELECT [Company_Name] as 'Company Name', [Entity_Code] as 'Entity Code', [YTD_Transactions] as 'YTD_Transactions', [Num_Reports_DB] as 'Num_Reports_DB', [Reports_Advanced_Workflow] as 'Reports_Advanced_Workflow', [Has_Customization] as 'Has_Customization',[TA_Trans_All] as 'TA Trans All', [TA_Trans_US] as 'TA Trans US', [Using_VAT] as 'Using VAT', [Total_Users] as 'Total Users',[Non_English_Langages] as 'Non English Langages',[Non_English_Users] as 'Non English Users', [Using_Offline] as 'Using Offline', [Using_Audit_Services] as 'Using Audit Services' from(v_customer_master_list) order by company_name" Else strSQL ="SELECT [Company_Name] as 'Company Name', [Entity_Code] as 'Entity Code', [YTD_Transactions] as 'YTD_Transactions', [Num_Reports_DB] as 'Num_Reports_DB', [Reports_Advanced_Workflow] as 'Reports_Advanced_Workflow', [Has_Customization] as 'Has_Customization',[TA_Trans_All] as 'TA Trans All', [TA_Trans_US] as 'TA Trans US', [Using_VAT] as 'Using VAT', [Total_Users] as 'Total Users',[Non_English_Langages] as 'Non English Langages',[Non_English_Users] as 'Non English Users', [Using_Offline] as 'Using Offline', [Using_Audit_Services] as 'Using Audit Services' from(v_customer_master_list) where lower(company_name) like '%" & company &"%' order by company_name" End If objAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, objConn)' Fill the dataset. objAdapter.Fill(objDataset) ' Create anew view. Dim oView As New DataView(objDataset.Tables(0)) ' Set up the data grid and bind the data. SimpleDataGrid.DataSource = oView SimpleDataGrid.DataBind() End Sub
Can anyone tell me what causes this type of error, what they think is wrong, or what IS wrong if someone wants to take the time to go through the code. Anything helps. Eh, I feel like one of those guys on a street corner with a sign when I say that.
Since the exception that was thrown is of type: System.Data.SqlClient.SqlException, then the error is in the sql statement itself and not in the code that is calling it.
can you run your sql statement in query analyzer?
|||
Visual Web Developer "helped" me out by adding "(" and ")" around my "from" statement in the SQL. Thanks for pointing out it had to be in the SQL.
I am having the same problem except I dont know where the problem is after reading your posts. Could someone please explain a bit more on where I can find/fix the error in SQL statement??
No comments:
Post a Comment