c# - Cannot insert into SQL Server 2012 - Error: "the property CommandText has not been initialized" -


I'm not seeing any errors, though I'm getting an exception:

Code:

  Private dataTable_employees; Private Systems Data SQLLient.SqlDataAdapter _adapter; Private datasets _ds; Receive private datatable employee {if _employees! = Null} returns _employees; else {_adapter = New SqlDataAdapter ("Select from employees'", Convert.ToString (ConfigurationManager.ConnectionStrings ["NORTHWNDConnectionString"])); _ds = new dataset (); _adapter.Fill (_ds); _ds.Tables [0] .tablename = "employee"; _employees = _ds.Tables [0]; Return worker; }}} Hashtable collectFormData (Telerik.Web.UI.GridCommandEventArgs e) {UserControl UserControl = (UserControl) e.Item.FindControl (GridEditFormItem.EditFormUserControlID) is protected; Hashtable new value = new hashtable (); New Price ["Country"] = (UserControl.FindControl ("TextBox7") text box) Text; New Price ["City"] = (UserControl.FindControl ("TextBox8") as text box) Text; New Price ["Area"] = (UserControl.FindControl ("TextBox9") as text box). Text; New Price ["Homephone"] = (User Control. FundControl ("Homephoneboxes") Rad mascadtextbox). Text; New Price ["Birthday"] = (UserControl.FindControl ("Birthday Picture" as RadDatePicker)). Selected dates Toasting (); NewValues ​​["TitleOfCourtesy"] = (UserControl.FindControl ("ddlTOC") as DropDownList). Selected Item.Value; New Value ["Notes"] = (UserControl.FindControl ("Textbox1") as text box). Text; NewValues ​​["address"] = (UserControl.FindControl ("TextBox6") as text box). Text; New value ["First name"] = (UserControl.FindControl ("Textbox2") as text box). Text; New value ["last name"] = (UserControl.FindControl ("TextBox3") text box). Text; newValues ​​["HireDate"] = (userControl.FindControl ("HireDatePicker") as RadDatePicker) .SelectedDate.ToString (); New value ["title"] = (UserControl.FindControl ("TextBox4") as text box). Text; Return new prices; } Protected Zero RadGrid1_InsertCommand (Object Source, GridCommandEventArgs E) {GridEditableItem editItem = e.Item as GridEditableItem; UserControl userControl = (UserControl) e.Item.FindControl (GridEditFormItem.EditFormUserControlID); Datarov Nimbrao = This Staff. Newro (); Hashtable new value = collectionfirm data (e); New value ["employee id"] = (come) this. Staff. Rao [this Staff. Ro Number -1] ["employee id"] + 1; _adapter.InsertCommand = New SqlCommand (SqlDataSource1.InsertCommand, New SqlConnection (Convert.ToString (ConfigurationManager.ConnectionStrings ["NORTHWNDConnectionString"]))); {foreach (enter new entrance entry) {newRow [(string entry). Kay] = log in. Value; _adapter.InsertCommand.Parameters.Add (New SqlParameter (Entry. (Value of Entry., Value)); _adapter.InsertCommand.Parameters.Add (new SqlParameter ("ReportsTo", SqlInt32.Null)); _adapter.InsertCommand.Parameters.Add (new SqlParameter ("PhotoPath", SqlString.Null)); _adapter.InsertCommand.Parameters.Add (new SqlParameter ("extension", SqlString.Null)); _adapter.InsertCommand.Parameters.Add (new SqlParameter ("PostalCode", SqlString.Null)); } This.Employees.Rows.Add (newRow); _adapter.InsertCommand.CommandType = CommandType.Text; _adapter.Update (_ds, "employee"); } Hold (Exception Pre) {RadGrid1.Controls.Add (New Little Control ("Unable to Insert Employee. Reason:" pre-message)); E.Canceled = true; }}   

Help! Why do not I have to struggle to solve it and do not give me exceptions?

"itemprop =" text ">

You do not have the InsertCommand property installed on the ASPX page in your SQL data source.



Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -