cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Trouble connecting to Neo4J from .NET

I am new both to Neo4J and C#. I copied a simple HelloWorld example, but from what I can tell it doesn't even connect to the DB. Initially I tried with the correct username/pwd/port, but when I saw that the create statement doesn't seem to be executed I tried with the wrong pwd/port hoping to see a DB connect error that would at least confirm that with correct credentials it did connect, but I get no error with the wrong credentials, which is confusing. Neo4J is started and I can execute queries in the Neo4J Browser. Any help would be appreciated. The code is below. Thank you for your time.

public async Task CreateNode(){
Console.WriteLine("CreateNode");
//IDriver driver = GraphDatabase.Driver("neo4j://localhost:7687", AuthTokens.Basic("neo4j", "pwd"));
IDriver driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", ""));
IAsyncSession session = driver.AsyncSession(o => o.WithDatabase("neo4j"));
try
{
Console.WriteLine("before run ");
IResultCursor cursor = await session.RunAsync("CREATE (person:Person {name: 'Fooo'})");
Console.WriteLine("after run");
await cursor.ConsumeAsync();
}
finally
{
await session.CloseAsync();
}

    await driver.CloseAsync();

}

5 REPLIES 5

Reiner
Graph Buddy

Hi @mmuslea,
welcome to the community!
Using C# I recommend working with Neo4jClient as it is much easier not only to connect but also to handle queries and results. GitHub - DotNet4Neo4j/Neo4jClient: .NET client binding for Neo4j

Best,
Reiner

Do you by any chance have any Neo4jClient basic code that I can start with, or a pointer to a "HellowWorld" Neo4jClient sample? Their documentation seems to be out of date for the current version of Neo4jClient and most of the sample code that I find is old and uses previous version.

Thank you for your help.

Maria

Thank you, I'll give this a try.

Reiner
Graph Buddy

In this issue there is a sample Program.zip that might help: Http and Bolt clients serialize input parameters differently · Issue #419 · DotNet4Neo4j/Neo4jClient...

Best,
Reiner

Thank you, I appreciate it.

Maria