sqldataadapter

How to add update parameter to SQLDataSource in c#

时光总嘲笑我的痴心妄想 提交于 2019-12-13 19:21:21
问题 In reference to my question, How to get boundfield value, or am I totally wrong? I am trying to add update parameter to a SQLDataSource using c# instead of ASP.NET but I am getting error, protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int userID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["userID"].ToString()); string userName = ""; string city = ""; string updateStatement = "Update myTable set userName=@userName, city=@city where userID=@userID";

C# SQLDataAdapter - Not inserting data into DB

試著忘記壹切 提交于 2019-12-13 05:21:25
问题 Here's what I got: User selects from a checklistbox of database names one they'd like to archive. Switch case in place to catch the selection. case "userSelection": sqlAdapter = CreateMyAdapter("dbName", true, sqlconn, null); sqlAdapter.SelectCommand.CommandText += ""; sqlAdapter.Fill(myDS.tableName); sqlAdapter.Dispose(); The adapter: private SqlDataAdapter CreateMyAdapter(string TableName, bool IncludeUpdates, SqlConnection sqlConn, SqlTransaction sqlTran) { SqlDataAdapter sqlAdapter = null

SQLDataAdapter.Update() not Updating when RowState = Modified

▼魔方 西西 提交于 2019-12-13 03:18:13
问题 I am trying to set up a program that, when a user updates an item description, will update the database upon the save of the form. I have set up everything I have found that is required and yet the adapter never updates. It selects and inserts great but never update. Code as follows: internal void UpdateDB(DataTable Items) { using ( var ItemsAdapter = new SqlDataAdapter("select * from dbo.Items", Properties.Settings.Default.ConnectionString) ) using ( var ItemsCB = new SqlCommandBuilder

SqlDataAdapter.Fill suddenly taking a long time

与世无争的帅哥 提交于 2019-12-13 00:59:33
问题 I have an application with a central DataTier that can execute a query to a data table using an SQLDataAdapter. None of this code has changed but now all queries are taking at least 10x as long to execute a query returning even one record. The only difference is that I have been using the app in a VM but the issue has started mid way through using the application. eg, the speed issue has not manifested itself from the start of using the VM, rather half way through. Has anyone else had an

How to Use an Update Statement in SQLDataAdapter

送分小仙女□ 提交于 2019-12-12 22:06:49
问题 I am trying to run an update statement after i built my sqldataadapter. I have column called INIT_PHASE in my table and if the INIT_PHASE is null or there is no data then i would like to set it to 1. I have tried but i can't seem to get it right the update statement. Pls. help. here is my code: string ID = ddlPractice.SelectedValue; string TYPE = DDL_TYPE.SelectedValue; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString);

Why am I getting “timeout” and “Cannot find table 0” and what preventive measures are at my disposal?

六眼飞鱼酱① 提交于 2019-12-12 05:07:38
问题 In the answer to a previous question here, I was advised to also ask about this related issue. Once in awhile, the report generation code I have throws two exceptions (they don't display to the user, and they think everything is hunky dory), but I get them emailed to me. The first is, " Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. " ...and the one that always follows quickly thereafter is, " Cannot find table 0 " The first

Calling a stored procedure with null parameters and SqlDataAdapter

喜欢而已 提交于 2019-12-12 04:37:15
问题 I have a stored procedure which I cann from my C# code. I am passing some parameters which I put in a HashTable first. It looks like that: paramname1 value1 paramname2 value2 paramname3 value3 Any of the values can be null . So now I am going through that hash and add the params to the adapter: foreach (DictionaryEntry entry in myHash) { adapter.SelectCommand.Parameters.AddWithValue(entry.Key.ToString(), entry.Value); } This works, but when I try to fill a DataSet, it fails: DataSet

Using an SQL Data Adapter to update and insert rows doesn't update (only inserts)

眉间皱痕 提交于 2019-12-11 23:14:49
问题 I am just playing around with this at the moment, ultimately I want to read a CSV file into memory and then insert the records into an SQL database. Existing records should be updated, records that are missing should be added. Records that don't exist in the new CSV shouldn't be deleted, however. I've been playing around the example from the MSDN library. I understand that the SqlDataAdapter can perform bulk updates quite quickly. I created a little mock app with a table called TempTestTable

SqlDataAdapter.FillSchema with stored procedure that has temporary table

妖精的绣舞 提交于 2019-12-11 19:25:24
问题 I'm running into a problem similar to this question here (Display DataType and Size of Column from SQL Server Query Results at Runtime) which has not had a solid solution. I wonder if anyone has found a solution or a work around for it. I can use SqlDataAdapter.Fill() with no problem, but .FillSchema() will report an error that the temp table I create in the stored procedure doesn't exist. My goal is to be able to fill the DataTable with data and the schema from the source. 回答1: I ran into

Would executing the SqlCommand be completely moot/redundant, and slow things down?

被刻印的时光 ゝ 提交于 2019-12-11 13:18:21
问题 Thanks to some tips and reminders here, I changed my code from this kludgy mess: try { DataSet dsUsage = new DataSet(); SqlConnection conn = new SqlConnection("SERVER=PROSQL05;DATABASE=platypusdata;UID=duckbill;PWD=poisonToe42;Connection Timeout=0"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = String.Format("Exec sp_ViewProductUsage_MappingRS '{0}', '{1}', '{2}'", mammal, dateBegin, dateEnd); da.SelectCommand = cmd; conn.Open(); da.Fill