sqlconnection

Connection String Is not Working Object instance reference is null

痞子三分冷 提交于 2019-12-26 12:39:26
问题 //'Object reference not set to an instance of an object.' Please Do not mark it as redundant question . I have tried almost all the methods to make a connection string first one is by : string connectionString = ConfigurationManager.ConnectionStrings["ClinicalConnectionString"].ConnectionString; the second one : string connectionstringgg = Properties.Settings.Default.ClinicalConnectionString; third method is by : ConnectionStringSettings connectionSetting = ConfigurationManager

Connection String Is not Working Object instance reference is null

こ雲淡風輕ζ 提交于 2019-12-26 12:39:07
问题 //'Object reference not set to an instance of an object.' Please Do not mark it as redundant question . I have tried almost all the methods to make a connection string first one is by : string connectionString = ConfigurationManager.ConnectionStrings["ClinicalConnectionString"].ConnectionString; the second one : string connectionstringgg = Properties.Settings.Default.ClinicalConnectionString; third method is by : ConnectionStringSettings connectionSetting = ConfigurationManager

Does my .Net SqlConnection object close on its own

一笑奈何 提交于 2019-12-25 06:31:15
问题 We have a simple loop process that does some stuff on some datarows. When commiting changes the new row and a SqlConnection object are passed to a method that handles the row change or addition. The process runs 5 times out of 10 all ok. The SqlConnection is opened at the start of the loop and closed after the loop however sometimes it does indeed close during the loop. The code is no calling close() at any point during the loop. So my questions is why it might close on it's own. Cheers For a

How to connect to SQL Server database using windows authentication remotely?

纵然是瞬间 提交于 2019-12-25 05:15:07
问题 I have a simple question, I was granted to a SQL Server database using windows authentication on my local machine, I need to know how to use this access on hosting server as well. For example I am in the middle of writing some C# code that pulls data from this database, I can run this code on my local machine with my windows authentication no problem, but I can't run it on expected hosting server because that server obviously can't connect to that database. I was just wondering how can I use

SQL: Make colors from color-table searchable

别等时光非礼了梦想. 提交于 2019-12-24 16:19:44
问题 I have a database with cards of different colors. A Card can be " Colorless " or one or more colors: " Red "," Green "," White "," Blue "," Black " The cards is in a Card table with id, name and some other card info, and the colors is in a Color table with name (ex:"Red"), a color code (ex:"r") and a color id And there are a Connection table with card_id and color_id So the question is how do a make colors searchable ? I like to be able to find all card that are "only Red" , aswell as all

What is the version 869 of SQL Server?

做~自己de王妃 提交于 2019-12-24 02:42:37
问题 I have VS 2017, SQL Server 2017 Configuration Manager and SQL Server 2017 management tools. My connection string is Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\test.mdf;Integrated Security=True;Connect Timeout=30 The version of connection: 13.00.4001 When I run my app in another PC I installed the SQL Server LocalDB 2017 and my app works perfectly! But when I copied the .MDF and .LDF files from that PC and tried to added them to new project I got this error: cannot be

What is the version 869 of SQL Server?

坚强是说给别人听的谎言 提交于 2019-12-24 02:42:11
问题 I have VS 2017, SQL Server 2017 Configuration Manager and SQL Server 2017 management tools. My connection string is Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\test.mdf;Integrated Security=True;Connect Timeout=30 The version of connection: 13.00.4001 When I run my app in another PC I installed the SQL Server LocalDB 2017 and my app works perfectly! But when I copied the .MDF and .LDF files from that PC and tried to added them to new project I got this error: cannot be

C# Form not inserting values into SQL Server database

耗尽温柔 提交于 2019-12-24 00:39:20
问题 I have a simple create a new user form which takes values from two text boxes, username and password. The button2 click event should take these values and insert them into the Users table in the database. However, when I run my code the message box appears to say the data has been added, I cannot see the data in the database using VS2010. See screen shot for the database connection in VS. I have also created a datasource of the database in VS. Any Ideas? Much appreciated. private void button2

How to handle exception without using try catch?

你说的曾经没有我的故事 提交于 2019-12-23 20:30:27
问题 using (SqlConnection con = new SqlConnection()) { try { con.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } This works fine. But I want to know can we handle exception without using try catch like some thing if else ? or is it mendetory to use try catch 回答1: There is no other mechanism to handle an exception other than try catch. It sounds like you want something like if(connection.DidAnErrorOccur) but that doesn't exist. 回答2: Only way is to check for all the conditions that

Which pattern is better for SqlConnection object?

耗尽温柔 提交于 2019-12-23 16:28:13
问题 Which pattern is better for SqlConnection object? Which is better in performance? Do you offer any other pattern? class DataAccess1 : IDisposable { private SqlConnection connection; public DataAccess1(string connectionString) { connection = new SqlConnection(connectionString); } public void Execute(string query) { using (SqlCommand command = connection.CreateCommand()) { command.CommandText = query; command.CommandType = CommandType.Text; // ... command.Connection.Open(); command