Search results
The simplest way to extract data from a DataTable when you have multiple data types (not just strings) is to use the Field<T> extension method available in the System.Data.DataSetExtensions assembly. var id = row.Field<int>("ID"); // extract and parse int var name = row.Field<string>("Name"); // extract string
23 lis 2024 · Gets or sets the string used to open a SQL Server database. public override string ConnectionString { get; set; } The connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string.
7 cze 2016 · SqlDataReader objects allow you to read data in a fast forward-only manner. You obtain data by reading each row from the data stream. Call the Close method of the SqlDataReader to ensure there are not any resource leaks.
12 paź 2023 · Basics of Database Connectivity in C#; Example of SQL Connection String in C#; In this tutorial, we’ll discover how to use the connection string feature of the C# programming language to perform different functionalities. Any programming language needs to be able to get data from a database.
7 lis 2021 · public static void Example(string questionNumber) { using var cn = new SqlConnection("TODO"); using var cmd = new SqlCommand { Connection = cn, CommandText = "Select * From[QuestionTable] WHERE questionno = @questionno" }; cmd.Parameters.Add(new SqlParameter("@questionno", SqlDbType.NVarChar)); cmd.Parameters["@questionno"].Value ...
14 lis 2018 · In this tip we look at a few examples of using .NET code to update and select data from SQL Server tables by creating a simple application and connection string to the SQL Server database.
7 maj 2012 · The easiest way to get the connection string is using the "Server Explorer" window in Visual Studio (menu View, Server Explorer) and connect to the server from that window. Then you can see the connection string in the properties of the connected server (choose the connection and press F4 or Alt+Enter or choose Properties on the right click menu).