Problem With Commandtype - Namespaceproblem?
Jan 7, 2008
Hi,
I have do some corretion in my aspxpage and the codebehind-page and have a problem right here (marked in bold):
Imports System.Data.SqlClient
Partial Public Class News
Inherits System.Web.UI.Page
Private Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.Insert Or _
DetailsView1.CurrentMode = DetailsViewMode.Edit Then
DirectCast(DetailsView1.FindControl("datumTextbox"), TextBox).Text = Now
End If
End Sub
Private Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
If Not IsDate(e.NewValues("Datum")) Then
Exit Sub
End If
Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("connpferde").ConnectionString)
Conn.Open()
Dim cmd As New SqlCommand()
cmd.Connection = Conn
cmd.CommandText = "UPDATE News SET Datum=@Datum WHERE ID=@ID"
cmd.Parameters.Add(New SqlParameter("@datum", CDate(e.NewValues("Datum"))))
cmd.Parameters.Add(New SqlParameter("@ID", e.NewValues("NewsID")))
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
Conn.Close()
End Sub
End Class
I'm told that the Name CommandType is not defined. When I kill CommandType and the equal sign and set the equal-sign combined with using the completingagent
it would suggested Data.CommandType.Text. On using that the running fails and Im told that the there is a missanderstanding with my Admin.master-Page.
How can I correct this phrase.
Regards
View 1 Replies
Mar 19, 2008
sir
i am using following code for hirarchy treeview.
and i am using asp.net with c#.and sql server.i
have 3 tables Indexmaster,sectormaster,indexsectormap.
i have error.
Error---
The CommandType enumeration value, 512,
is not supported by the .Net Framework
SqlClient Data Provider.
Parameter name: CommandType
my code---
sqlcon.ConnectionString = "Data source=tipl5;initial catalog=eERS;uid=gayatri;pwd=gayatri;Connect Timeout=120";
sqlcon.Open();
cmd.Connection =sqlcon;
cmd.CommandType = CommandType.TableDirect;
cmd.CommandText = "IndexMaster";
sqlda.SelectCommand = cmd;
sqlda.Fill(ds, "IndexMaster");
cmd.CommandText = "IndexSectorMap";
sqlda.SelectCommand = cmd;
sqlda.Fill(ds, "IndexSectorMap");
cmd.CommandText = "SectorMaster";
sqlda.SelectCommand = cmd;
sqlda.Fill(ds, "SectorMaster");
ds.Relations.Add("Root", ds.Tables["IndexMaster"].Columns["IndexCode"], ds.Tables["IndexSectorMap"].Columns["tIndexCode"]);
ds.Relations.Add("Secondary", ds.Tables["IndexSectorMap"].Columns["tSectorCode"], ds.Tables["SectorMaster"].Columns["SectorCode"]);
FpSpread1.DataSource = ds;
regards
gayatri
View 4 Replies
View Related
Oct 10, 2006
When I open a report definition, go to a dataset and open it, the CommandType ALWAYS goes to "Text". I don't want "Text", I want "Stored Procedure". I NEED "Stored Procedure".
I have also found that the CommandText for a different dataset will change even though I have not opened it.
I guess the only solution I have is to open the RDL files, search for the dataset entries and then fix the XML code. This is a real pain in the buttocks when I am working with 300+ reports.
Is there a fix for this bug? Or are you going to FORCE everyone to use "Text"?
I am trying to finish this project so that we can release it to our customers but now I have to wonder why we decided to go with Reporting Services, especially now that we have to do double edits on each and every report.
Steven Broomhead
Optimum Solutions, Inc.
View 3 Replies
View Related
Dec 12, 2004
If i am using SqlCommand Class and the CommandType of it is Text, then will it add "sp_executesql N" in front of the sql command automatically in fact, just like SqlDataAdapter?
View 3 Replies
View Related
Feb 23, 2007
i am using visual web developer 2005 and SQL 2005 with VB as the code behindi am using INSERT command like this Dim test As New SqlDataSource() test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString() test.InsertCommandType = SqlDataSourceCommandType.Text test.InsertCommand = "INSERT INTO try (roll,name, age, email) VALUES (@roll,@name, @age, @email) " test.InsertParameters.Add("roll", TextBox1.Text) test.InsertParameters.Add("name", TextBox2.Text) test.InsertParameters.Add("age", TextBox3.Text) test.InsertParameters.Add("email", TextBox4.Text) test.Insert() i am using UPDATE command like this Dim test As New SqlDataSource() test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString() test.UpdateCommandType = SqlDataSourceCommandType.Text test.UpdateCommand = "UPDATE try SET name = '" + myname + "' , age = '" + myage + "' , email = '" + myemail + "' WHERE roll 123 " test.Update()but i have to use the SELECT command like this which is completely different from INSERT and UPDATE commands Dim tblData As New Data.DataTable() Dim conn As New Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True") Dim Command As New Data.SqlClient.SqlCommand("SELECT * FROM try WHERE age = '100' ", conn) Dim da As New Data.SqlClient.SqlDataAdapter(Command) da.Fill(tblData) conn.Close() TextBox4.Text = tblData.Rows(1).Item("name").ToString() TextBox5.Text = tblData.Rows(1).Item("age").ToString() TextBox6.Text = tblData.Rows(1).Item("email").ToString() for INSERT and UPDATE commands defining the command,commandtype and connectionstring is samebut for the SELECT command it is completely different. why ?can i define the command,commandtype and connectionstring for SELECT command similar to INSERT and UPDATE ?if its possible how to do ?please help me
View 2 Replies
View Related