question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TSQLStatementReader.ParseStatements throws Object reference not set to an instance of an object. exception

See original GitHub issue

Discussed in https://github.com/bruce-dunwiddie/tsql-parser/discussions/92

<div type='discussions-op-text'>

Originally posted by muneeebsheikh June 3, 2022

I am trying to parse this select statement

SELECT system_user

but the method TSQLStatementReader.ParseStatements() throws

Object reference not set to an instance of an object.

stack trace

at TSQL.Elements.Parsers.TSQLSelectColumnParser.Parse(ITSQLTokenizer tokenizer)
at TSQL.Clauses.Parsers.TSQLSelectClauseParser.Parse(ITSQLTokenizer tokenizer)
at TSQL.Statements.Parsers.TSQLSelectStatementParser.Parse()
at TSQL.Statements.Parsers.TSQLSelectStatementParser.TSQL.Statements.Parsers.ITSQLStatementParser.Parse()
at TSQL.TSQLStatementReader.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TSQL.TSQLStatementReader.ParseStatements(String tsqlText, Boolean useQuotedIdentifiers, Boolean includeWhitespace)
at Testing.App.SQLMethods.ParseSQLStatements(String sqlText) in D:\Testing.App\Testing.App\SQLMethods.cs:line 72

Kindly help me out if I am missing something or that’s the expected behavior. This is how I’m doing:

string sqlText = @"SELECT system_user;";

var statements = TSQLStatementReader.ParseStatements(sqlText);

I am using nuget package version: 2.1.0

interestingly if I change the select statement to this

SELECT system_user from tbl;

I just added a FROM clause and it works, it gives me the statement and tokens.

</div>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
muneeebsheikhcommented, Jun 8, 2022

@bruce-dunwiddie thanks now its fixed!

0reactions
bruce-dunwiddiecommented, Jun 6, 2022

@muneeebsheikh , I pushed a new build, v2.2.1, and verified the functionality is now updated with the version pulled back from NuGet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Server 2012 error: object reference not set to an ...
I could solve the error. Repair the SQL Server. Go to Add/remove programs Microsoft SQL Server 2012(x64) -> Uninstall/Change -> Repair . Select ......
Read more >
"Object reference not set to an instance of an ...
I have installed SSMS 18.10 and I have connected to Azure SQL Managed Instance, then trying to edit SQL Agent Job always failing...
Read more >
Why doesn't "object reference not set to an instance of an ...
We're launching a system, and we sometimes get the famous exception NullReferenceException with the message Object reference not set to an ...
Read more >
Object reference not set to an instance of an object
This article provides information on the error "Object reference not set to an instance of an object" in custom code.
Read more >
Object reference not set to an instance of an object while ...
It simply means that some member/variable of some reference type is dereferences by using and of its instance (non-static) members, which ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found