ado.net

Display all child records of a parent in DataGridView

流过昼夜 提交于 2019-12-24 17:24:49
问题 I am new to .NET, and I don't really understand how it works. I have this project I have to do and I'm asked to display all parent records, and when I select a parent record there should be displayed all its children. So far I managed to display all the parent records, using a DataGridView. private void display_btn_Click(object sender, EventArgs e) { dg.DataSource = data_set.Tables[0]; } The following code works but it displays all the records from the child. I know that I should compare

Syntax error (missing operator) in query expression

微笑、不失礼 提交于 2019-12-24 12:14:11
问题 I am working with C# Form based application with Access as DB. And getting this error Syntax error (missing operator) in query expression 'Request_Data = 12/15/2010 12:00:00 AM AND User_ID = '1''. On this query. String sql = "Select * From Requests WHERE Request_Data = 12/15/2010 12:00:00 AM AND User_ID = '1'"; What's wrong in this query? 回答1: I'm guessing you need quotes hashes around the datetime: String sql = "Select * From Requests WHERE Request_Data = #12/15/2010 12:00:00 AM# AND User_ID

ADO.NET Connection Pool concurency issue with SQL Azure or How we cannot scale out our Web App

亡梦爱人 提交于 2019-12-24 10:55:21
问题 We are having issues to scale out our ASP.NET Web API on Azure because of our SQL Azure DB. The issue is that our Web/Business SQL Azure DB supports a maximum of 180 concurrent requests. At multiple occasions, we've hit that limit, and the following exception is thrown: Resource ID : 1. The request limit for the database is 180 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' To prevent that to happen, we explicitly set the "Max Pool Size" property of our

ADO.NET for connecting Oracle Database on server

无人久伴 提交于 2019-12-24 09:54:25
问题 Recently we have developed an application which connects to oracle database for fetching records. For fetching records, we are using OLEDB for Oracle. Application runs fine on my machine by connectng properly with Oracle ,since i have oracle client installed on my machine. Now i tried to test application on another machine, which doesnot have any oracle instance/Client installed on his machine. Application fails to connect to oracle central DB Server. Is it necessary for users to install

Generate a string like a WHERE statement by a dictionary

廉价感情. 提交于 2019-12-24 09:39:55
问题 I know we should never do this: string select = "SELECT * FROM table1 "; string where = "WHERE Name = '" + name + "' "; string sql = select + where; //execute the sql via ADO.NET because of sql injection, because name can contain the char ' , because of another 100 reasons. But now I have to do something similiar. I have a Dictionary<string, object> whose data look like: Key(string) Value(object) "Name" "Bob" //string "ID" 10092L //long "Birthday" 1980-05-07 00:00:00 //DateTime "Salary" 5000

MS Access DB doesnt save changes after execution (C#)

岁酱吖の 提交于 2019-12-24 09:39:25
问题 I have the following code for using an access database OleDbConnection con = new OleDbConnection(myproject.Properties.Settings.Default.myDBConnectionString); con.Open(); OleDbCommand command = new OleDbCommand("INSERT INTO components (name) VALUES (@p_col1)", con); command.Parameters.Add("@p_col1", OleDbType.VarChar).Value = "test row"; int rows = command.ExecuteNonQuery(); At this point rows value is 1 and when I make select queries after that the row inserted is available. The problem comes

TSQL try catch transaction error handling, transaction count mismatch

纵饮孤独 提交于 2019-12-24 09:39:19
问题 I have a sproc that I am calling from C# with a transaction by doing: using (var dbContext = PowerToolsDatabase.GetDataContext()) { dbContext.Connection.Open(); using (dbContext.Transaction = dbContext.Connection.BeginTransaction(System.Data.IsolationLevel.Serializable)) { foreach (var element in package.AddOrUpdateElements) { dbContext.usp_Element_Commit( /* args */); } dbContext.Transaction.Commit(); } } And in that sproc there is a try catch, and a RAISERROR inside the try part that is

SqlDataAdapter.Fill takes time more than CommandTimeout

别等时光非礼了梦想. 提交于 2019-12-24 09:26:34
问题 When I execute this query, though I set the ConnectionTimeOut to 1 second, SqlDataAdapter.Fill takes more time than 65 second. and timeout not work. var cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * FROM [tblLargeData]"; con.Open(); cmd.Connection = con; var ds = new DataSet(); var da = new SqlDataAdapter(cmd); da.SelectCommand.CommandTimeout = 1; da.Fill(ds); tblLargeData is a table that contains large data in SQL server database. But when I change

SQLCacheDependency with ADO.NET Entity Model

百般思念 提交于 2019-12-24 07:27:24
问题 Does SQL Cache Dependency work with the ADO.NET Entity Model? Please give me some example link of something. 回答1: This is an msdn link to SqlCacheDependency and here's for LINQ & SqlCacheDependency 回答2: But linq and ADO.Net are'nt not really the same thing 来源: https://stackoverflow.com/questions/901130/sqlcachedependency-with-ado-net-entity-model

Invalid attempt to call Read when reader is closed

↘锁芯ラ 提交于 2019-12-24 07:13:05
问题 I'm kind of struggling trying to get this datagrid to bind. Everytime I run my code, I get an error message stating, "Invalid attempt to call Read when reader is closed". I don't see where I am closing my reader. Can you please help me? My code for loading the datagrid is below: protected void LoadGrid() { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings["VTC"].ConnectionString; conn.Open(); string sql = "select * from roi