dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.24k stars 5.88k forks source link

Connection string builder code error #39682

Open Jymms opened 7 months ago

Jymms commented 7 months ago

Type of issue

Code doesn't work

Description

I can't find what you're using as the "baseConnectionString" so I figured it was the Data Source Path. That gives me an error "System.ArgumentException: 'Format of the initialization string does not conform to specification starting at index 0.'

I added DataSource = SomeFilePath, as the first line inside the { } Which consistent with the information up to the Example.

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/connection-strings

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/data/sqlite/connection-strings.md

Document Version Independent Id

8eec3e85-0630-15db-ff40-c89920b89526

Article author

@ajcvickers

Metadata

AntonyNET commented 7 months ago

Hi, give your code sample please

Jymms commented 7 months ago

Hi AntonyNet, the issue is not my code it's lack of explanation in the example. If the page is written for learning how to connect to / create a SQLite database I would assume it's for beginners. The example code shows

var connectionString = new SqliteConnectionStringBuilder(baseConnectionString) { Mode = SqliteOpenMode.ReadWriteCreate, Password = password }.ToString();

No where can I find what baseConnectionString is so I guessed a few different strings there with a SaveFileDialog.FileName. It may be obvious to a schooled programmer but not so much for someone that's trying to learn the basics.

This is missing DataSource so one might assume that's baseConnectionString

The examples below this code block are all connectionstring and seem to be the result of the .ToString() from the above code block but that's connectionString not connectionstring.