How Can I Add 'InsertCommand' In SqlDataSource?

Dec 17, 2007

I need to add an 'InsertCommand' to my query via sqldatasource, but i cannot see this option, i only have the 'order', 'where' and 'advanced' option, could you please advice?

View 5 Replies


ADVERTISEMENT

A SqlDataSource Can Execute Two InsertCommand??

May 3, 2007

hi everyone
i have a SqlDataSourceand i want execute two T-Sql (two InsertCommand)but not successHow did i do this?
Thanks
1      Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted2            Dim SDSTemp As SqlDataSource = Nothing3            Try4                SDSTemp = New SqlDataSource(CnStr, "")5                SDSTemp.InsertCommandType = SqlDataSourceCommandType.Text6                SDSTemp.InsertCommand = "INSERT INTO Table1 (id,t1,t2) VALUES (@id,@t1,@t2)"7                Dim id As String = e.Command.Parameters("@id").Value.ToString8                SDSTemp.InsertParameters.Add("id", id)9                SDSTemp.InsertParameters.Add("t1", CType(FormView1.FindControl("TextBox1"), TextBox).Text)10               SDSTemp.InsertParameters.Add("t2", CType(FormView1.FindControl("TextBox2"), TextBox).Text)11               SDSTemp.Insert()12   13              SDSTemp.InsertCommand = "INSERT INTO Table2 (id) VALUES (@id)"14   15              SDSTemp.InsertParameters.Add("id", id)16   17              SDSTemp.Insert()18           Catch ex As Exception19               Message.Text = ex.Message.ToString20           End Try21       End Sub22    

View 1 Replies View Related

InsertCommand Using Data From A Second SqlDataSource - ASP.NET 2.0

Nov 29, 2007

I have a process that inserts a new record using the InsertCommand of a SqlDataSource.  As part of the process, I need to insert data the is available in a different SqlDataSource.  I was trying this with the Insert Parameter:

View 1 Replies View Related

Sqldatasource InsertCommand && Oracle Sequence.

Jan 10, 2006

I cannot get an Oracle sequence to work in an Sqldatasource InsertCommand:I've tried the following:
InsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (whsts_id.nextval,:CUSTOMER_ID)And: InsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (:Testing,:CUSTOMER_ID)<asp:Parameter DefaultValue="whsts_id.nextval" Name="testing" />AndInsertCommand='INSERT INTO "WHSTSTICKETS" ("WHSTS_ID", "CUSTOMER_ID") VALUES (whsts_id.nextval,:CUSTOMER_ID)
This is the classic error I get:ORA-01036: illegal variable name/numberI did review the asp.net forums before posting this.  As well, I've looked through the VWD 2005 documentation and cannot find the answer to this question.  Argg!  Any help is appreciated.   I've also worked to try and find out how to view the SQL that the Sqldatasource is generating, but I can't find the answer to this either.

View 8 Replies View Related

Passing A String Into The InsertCommand Of SqlDataSource At The @color Character

Apr 27, 2007

Ok, so I'm a JSP guy and thing it should be easy to replace "@color" with t_color after I initialized it to red by         String t_color = "red";and then calling the insert         SqlDataSource1.Insert();here is insert command:             InsertCommand="INSERT INTO [favcolor] ([name], [color]) VALUES (@name, @color)"  I've tried       InsertCommand="INSERT INTO [favcolor] ([name], [color]) VALUES (@name, "+ t_color+")"  Ive tried        InsertCommand="INSERT INTO [favcolor] ([name], [color]) VALUES (@name, "<%$ t_color %>" )"   Is there any easy way to do this? or Can I set it like @color = t_color?  Thanks in advance for ANY help JSP turning ASP (Maybe)Dan 

View 4 Replies View Related

Abort Insertcommand

Apr 1, 2007

hey. I have a formview - inertitemtemplate. In here I have a button with CommandName="Insert". In code behind under FormView1.ItemInserting I want to be able to abort the inserting in some cases. Is this possible? 

View 1 Replies View Related

Two Inserts In One InsertCommand

Apr 11, 2007

I'm using a SQLDataSource and trying to do two inserts into two different tables with one InsertCommand, but it's not working. Here's the code I'm trying to use. Do you see anything wrong with the syntax? I keep getting an error that says error near ','  but I can't figure out why. Thanks
 
InsertCommand="INSERT INTO [OurProjects] ([Title], [Description], [Location], [Anchors], [Size], [Developer], [DesignBuilder], [Architect], [ImageName], [MapName], [ProjectTypeAbbrev], [Deleted]) VALUES (@Title, @Description, @Location, @Anchors, @Size, @Developer, @DesignBuilder, @Architect, @ImageName, @MapName, @ProjectTypeAbbrev, @Deleted),
INSERT INTO [OurProjectsImages] ([OurProjectsID], [ImageMonthName], [SwfName]) VALUES (@OurProjectsID, @ImageMonthName, @SwfName)"

View 2 Replies View Related

InsertCommand, Add Strings...

Nov 23, 2007

I am submitting a telephone number into a table. I have 3 boxes for the telephone number. Telephone1,Telephone2,Telephone3. I need to insert the values of the 3 text boxes into a column called phone in my table.
 so like
InsertCommand="INSERT INTO customer_mod (phone)  Values (@Telephone_1)
 <asp:formparameter name="Telephone_1" formfield="Telephone1+Telephone2+Telephone3" />
 I don't think that is gonna work, so can you please help me make that code work?

View 3 Replies View Related

Insertcommand @value Null...

Apr 29, 2008

My problem is when trying to insert it's coming back that "Column 'textmenu' cannot be null" who is right for that fieldCode below: <script language="vb" runat="server">    sub Page_Load(s as Object, e as EventArgs)        if ( Page.IsPostBack ) then            Exit sub        end if    end sub    private sub SubmitBtn_Click(s As Object, e As EventArgs)        SqlDataSource1.Insert()    end sub</script>    <asp:sqldatasource id="SqlDataSource1" runat="server"        ConnectionString="<%$ ConnectionStrings:test %>" ProviderName="<%$ ConnectionStrings:test.ProviderName %>"            insertcommand="INSERT INTO test (textmenu) VALUES (@somevalue)">        <insertparameters>            <asp:ControlParameter PropertyName="text" ControlID="CompanyNameBox" Name="somevalue" Type="String" />        </insertparameters>    </asp:sqldatasource>    <asp:textbox id="CompanyNameBox" runat="server" />    <asp:Button id="submitButton" Text="Envoyer" OnClick="SubmitBtn_Click" runat="server"/></asp:Content>  So I change the constrain to accept "null" value then I check in the table database and there is a record but no valueSo I change the sql command to "INSERT INTO test (textmenu) VALUES ('test')" and it's working I have a record and the value "test" in the tableI don't know what I'm doing wrong up here with the @value. Can anyone help? Thanks  

View 10 Replies View Related

NVarchar And SelectedValue And InsertCommand

Dec 19, 2007

Hi guys,I've got a  problem  inserting data into my db.I've created a NVARCHAR column and I'm using SelectedValue Parameters.I only have a problem in the INSERT mode.The UPDATE and DELETE are working fine.All the fields can be updated or deleted, but I can't insert new data inside my db.I've changed one column to NVARCHAR :   "reference"I use NVARCHAR because I have some Arabic Fields (unicode) into my db.But I've copy-pasted everything about the SqlDataSource.10x a lot anyway !  ASP.NET using MS Visual Studio 2005 :.... <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"        OldValuesParameterFormatString="original_{0}"        OnDeleted="SqlDataSource2_Deleted"        OnUpdated="SqlDataSource2_Updated"        OnInserted="SqlDataSource2_Inserted"        SelectCommand=            "SELECT [reference], [ddf], [description], [quantity], [pru], [supname], [catname]                FROM [Products]                WHERE ([reference] = @reference)"        InsertCommand="INSERT INTO [Products]                ([reference], [ddf], [description], [quantity], [pru], [supname], [catname])                VALUES (@reference, @ddf, @description, @quantity, @pru, @supname, @catname)"        UpdateCommand="UPDATE [Products]                SET [ddf] = @ddf,                    [description] = @description,                    [quantity] = @quantity,                    [pru] = @pru,                    [supname] = @supname,                    [catname] = @catname               WHERE [reference] = @original_reference"               DeleteCommand="DELETE FROM [Products] WHERE [reference] = @original_reference">                <SelectParameters>            <asp:ControlParameter ControlID="GridView1" Name="reference" PropertyName="SelectedValue" Type="String" />              </SelectParameters>                <InsertParameters>            <asp:Parameter Name="reference"                Type="String" />            <asp:Parameter Name="ddf"                Type="DateTime" />             <asp:Parameter Name="description"                Type="String" />            <asp:Parameter Name="quantity"                Type="String" />            <asp:Parameter Name="pru"                Type="Decimal" />              <asp:Parameter Name="supname"                Type="String" />              <asp:Parameter Name="catname"                Type="String" />        </InsertParameters>                <UpdateParameters>            <asp:Parameter Name="ddf"                Type="DateTime" />             <asp:Parameter Name="description"                Type="String" />            <asp:Parameter Name="quantity"                Type="String" />            <asp:Parameter Name="pru"                 Type="Decimal" />              <asp:Parameter Name="supname"                Type="String" />              <asp:Parameter Name="catname"                Type="String" />            <asp:Parameter Name="original_reference"                Type="String" />           </UpdateParameters>                <DeleteParameters>            <asp:Parameter Name="original_reference"                Type="String" />        </DeleteParameters>            </asp:SqlDataSource>SQL SERVER 2005 : Create Database FileUSE masterGOIF EXISTS(SELECT * FROM sysdatabases        WHERE name='Products')    DROP DATABASE ProductsGOCREATE DATABASE ProductsON (    NAME=Product,    FILENAME = 'C:WebAppApp_DataProducts.mdf',    SIZE=10 )GOUSE ProductsGOCREATE TABLE Categories (    catname         VARCHAR(25)     NOT NULL,    PRIMARY KEY (catname) )GOCREATE TABLE Suppliers (    supname        VARCHAR(25)    NOT NULL,    tel            VARCHAR(50)    ,    cell        VARCHAR(50)    ,    fax            VARCHAR(50)    ,    pob            VARCHAR(25)    ,    address        VARCHAR(300)    ,    nearby        VARCHAR(100)    ,    website        VARCHAR(100)    ,    email        VARCHAR(100)    ,    skypephone    VARCHAR(100)    ,    PRIMARY KEY (supname) )GOCREATE TABLE Products (    reference     NVARCHAR(25)     NOT NULL,    ddf         DATETIME        NOT NULL,    description VARCHAR(50)     NOT NULL,    quantity     VARCHAR(10)     NOT NULL,    pru         MONEY             NOT NULL,    supname        VARCHAR(25)    NOT NULL,    catname        VARCHAR(25)        NOT NULL,    pv            MONEY            NOT NULL,    PRIMARY KEY(reference),    FOREIGN KEY(catname) REFERENCES Categories(catname),    FOREIGN KEY(supname) REFERENCES Suppliers(supname) )GO 

View 3 Replies View Related

InsertCommand.ExecuteNonQuery() And Violation Of PrimaryKey

Jan 15, 2007

Hey,
I have a page that inserts into a customers table in the DataBase a new customer account using this function:
Public Function InsertCustomers(ByRef sessionid, ByVal email, ByVal pass, Optional ByVal fname = "", Optional ByVal lname = "", Optional ByVal company = "", Optional ByVal pobox = "", Optional ByVal add1 = "", Optional ByVal add2 = "", Optional ByVal city = "", Optional ByVal state = "", Optional ByVal postalcode = "", Optional ByVal country = 0, Optional ByVal tel = "")
Dim result As New DataSet
Dim tempid As Integer
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("Conn"))
Dim Adcust As New SqlDataAdapter
Adcust.InsertCommand = New SqlCommand
Adcust.SelectCommand = New SqlCommand
Adcust.InsertCommand.Connection = conn
Adcust.SelectCommand.Connection = conn
sessionExists(email, sessionid, 1)
conn.Open()
If fname = "" Then
Adcust.InsertCommand.CommandText = "Insert Into neelwafu.customers(email,password,sessionid) Values('" & email & "','" & pass & "','" & sessionid & "')"
Else
Dim strsql As String
strsql = "Insert Into neelwafu.customers"
strsql = strsql & "(sessionid,email,password,fname,lname,company,pobox,address,address2,city,state,postalcode,countrycode,tel) values("
strsql = strsql & "'" & sessionid & "','" & email & "','" & pass & "','" & fname & "','" & lname & "','" & company & "','" & pobox & "','" & add1 & "','" & add2 & "','" & city & "','" & state & "','" & postalcode & "', " & country & ",'" & tel & "')"
Adcust.InsertCommand.CommandText = strsql
End If
Adcust.InsertCommand.ExecuteNonQuery()
Adcust.SelectCommand.CommandText = "Select Max(id) from neelwafu.Customers"
tempid = CInt(Adcust.SelectCommand.ExecuteScalar())
conn.Close()
Return tempid
End Function
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Now, I am getting an error:
Violation of PRIMARY KEY constraint 'PK_customers_1'. Cannot insert duplicate key in object 'customers'. The statement has been terminated.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The customers table has as a primary key the 'email'.....
so plz can I know why am I getting this error ????
Thank you in advance
Hiba

View 4 Replies View Related

Change The InsertCommand Of A Datasource Before Insert

Jun 8, 2006

Hi,
I am trying to set the InsertCommand of a SqlDataSource prior to a new record being created in DetailsView. It has to be changed because certain fields are not being used in one scenerio and it is causing Null's to be written to the database.
Here is what I have tried:
I set the Insert command on page Load:
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource3.InsertCommand = "Insert into table (name,realName,type,extraValue) VALUES (@name,@realName,@type,@extraValue)";
}
But I don't want to insert the "extraValue if a certain condition is true so I want to change the insert command to SqlDataSource3.InsertCommand = "Insert into table (name,realName,type) VALUES (@name,@realName,@type)
I tried to do that in the following:
protected void DetailsView1_ItemInserted(Object sender, System.Web.UI.WebControls.DetailsViewInsertedEventArgs e)
{
SqlDataSource3.InsertCommand = "Insert into table (name,realName,type,extraValue) VALUES (@name,@realName,@type,@extraValue)";
if (e.Exception != null)
{
ErrorMessageLabel.Text = "An error occured while entering this record. Please verify you have entered data in the correct format.";
e.ExceptionHandled = true;
Response.Write(e.Exception);
}
GridView1.DataBind();
GridView1.DataBind();
}
But it doesn't seem to change,
Any Help would be appreciated,
Doug

View 5 Replies View Related

Help On Using SqlDataAdapter InsertCommand Targeting LocalSqlServer Connection

Apr 29, 2008

 I am trying to use a sqldataadapter to log a record to a table with a stored procedure call. I am getting the following error: "System.NullReferenceException: Object reference not set to an instance of an object.
at ContactUs.LogEmail() in c:inetpubwwwrootMDWelcomeContactUs.aspx.vb:line 55"Here is my code: Protected Sub LogEmail()
'Trace.IsEnabled = True
Dim strConnect As String = ConfigurationManager.ConnectionStrings("LocalSqlServer").ToString
Dim strCommandText As String = "dbo.EmailsLogged_Insert"
Dim objConnect As New SqlConnection(strConnect)
Try
objConnect.Open()
Dim objDataAdapter As New SqlDataAdapter(strCommandText, objConnect)
objDataAdapter.InsertCommand.CommandText = strCommandText'this is line 55 in my source where error is thrown
objDataAdapter.InsertCommand.CommandType = CommandType.StoredProcedure
With objDataAdapter.InsertCommand.Parameters
.Add("@emailaddress", SqlDbType.VarChar, 255).Value = UsersEmail.Text
.Add("@subject", SqlDbType.VarChar, 255).Value = Subject.Text
.Add("@company", SqlDbType.VarChar, 255).Value = Company.Text
.Add("@phone", SqlDbType.VarChar, 255).Value = Phone.Text
.Add("@emailbody", SqlDbType.VarChar, 255).Value = Body.Text

End With
objDataAdapter.InsertCommand.ExecuteNonQuery()
objConnect.Close() 'then close the connection
Catch SQLError As SqlException
Response.Write("<H1>SQL Exception:</H1>")
Response.Write("<h2>" & SQLError.Procedure & "</h2><br />")
Response.Write("<h2>" & SQLError.Message & "</h2><br />")
Dim lineNum As Integer
Dim errMsgArray() As String = Split(SQLError.StackTrace, vbCrLf, , Microsoft.VisualBasic.CompareMethod.Text)
Do While lineNum <= errMsgArray.Length - 1
If Trim$(errMsgArray(lineNum)) <> "" Then
Response.Write("<br>" & errMsgArray(lineNum))
End If
lineNum = lineNum + 1
Loop
Catch objError As Exception
Dim oMsg As String
'display error details
oMsg = "<b>* Error while accessing data</b>.<br />" _
& objError.Message & "<br />" & objError.Source

Trace.Write(oMsg)
Response.Write(oMsg)
Response.End()
End Try
End Sub
 I think the connection is OK (debugging shows that objConnect.State is open) but I am unclear why this is incorrect code here. 

View 2 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Individual SqlDataSource() Or Common SqlDataSource() ?

Mar 8, 2007

i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me

View 1 Replies View Related

Asp:sqldatasource - Sum And Contains

Aug 20, 2006

I have an asp:sqldatasource which is bound to a gridviewIn addition to this I would like it to a) see if there is a specif row/ item in it (ie item_id = 10 for any of the rows it has received) as I conditionally want to show another item outside of the gridview subject to if it is in the gridview or notb) show the sum of all the values within a certain column of returned rowsMany thanks

View 1 Replies View Related

SqlDataSource

Oct 11, 2006

How do I get the result of this select into a variableDim sqldsFindUserId As SqlDataSource = New SqlDataSource        sqldsFindUserId.ConnectionString = ConfigurationManager.ConnectionStrings("bluConnectionString2").ToString        sqldsFindUserId.SelectCommandType = SqlDataSourceCommandType.Text        Dim myUserIdCmd As String = "select pkUser from tblUsers where strDisplayName='" + myDisplayname + ""        sqldsFindUserId.SelectCommand = myUserIdCmd  '  The result  of this select statement is to be stored in a variable, how do I do it?

View 2 Replies View Related

SqlDatasource

Dec 18, 2006

Hi all

View 2 Replies View Related

Sqldatasource

Jan 15, 2007

hi all,
in all my 2.0 learnings and books i keep coming across the page element <asp:sqldatasource>.
I have always (in 1.1) used server side connections and adapters to bind my Sql datasets to any control needed.  Now that im learning 2.0 im finding it difficult to understand using control on the page to bind my data.  Can someone explain the benefits of using this data source?  Ideally i would like to keep my data access layer separate from my presentation layer but i'd really like to understand why this method seems so popular.
thanks in advance,
mcm

View 2 Replies View Related

Using SQLDataSource

Feb 23, 2007

Hi, I am new to ASP.NET 2.0 and I am trying to use VWB to bind my web site to a SQL Express edition. I used SQLDataSource to specify the .mdf file so I can connect to my tables but when I click on the advanced button to generate the Insert, Update, Delete SQL I find it grayed out and it cannot be clicked. I looked into several tutorials online and I couldn't find the problem, can anyone explain what I am missing or doing wrong? Any suggestion is very appreciated. Thanks 

View 2 Replies View Related

SQLDataSource

Mar 30, 2007

SELECT * FROM [CONTACTS] WHERE @ddl_value LIKE '%@txt_value%'
 
Why doesn't this not working
I am using SQLdatasource control to bind a gridview
If my query is wrong then what might be the correct one to work with like operator in the sqldatasource
Can any ony help me!

View 4 Replies View Related

SqlDataSource

Apr 12, 2007

Hello All,
 I have quick question ..
In my aspx page i have gridview  and Sql DataSource  object as you can see
<asp:sqldatasource id="SqlDataSource1" runat="server" ></asp:sqldatasource>
 
<asp:gridview id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1">
<columns>
<asp:boundfield datafield="breakdownid" headertext="breakdownid" insertvisible="False"
readonly="True" sortexpression="breakdownid" />
<asp:boundfield datafield="ticketno" headertext="ticketno" sortexpression="ticketno" />
<asp:boundfield datafield="systemtype" headertext="systemtype" sortexpression="systemtype" />
<asp:boundfield datafield="break_date" headertext="break_date" readonly="True" sortexpression="break_date" />
<asp:boundfield datafield="subject" headertext="subject" sortexpression="subject" />
<asp:boundfield datafield="status" headertext="status" sortexpression="status" />
<asp:boundfield datafield="prioritylevel" headertext="prioritylevel" sortexpression="prioritylevel" />
<asp:boundfield datafield="mobiletype" headertext="mobiletype" sortexpression="mobiletype" />
</columns>
</asp:gridview>
In codebehind file  i call a function to get data from database. what i want is to bind the result to the sqlDataSourse not the gridview.
 I need to have the SqlDataSourse thier..  Any help please
 
 
Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim objReader As New Dynamic.Reportsdemo
SqlDataSource1 = .objReader.Get_Tickets(1, 0, "all")
 
SqlDataSource1.DataBind()
objReader.objconnection.Close()
 
End If
End Sub
Thanks.
 
 

View 1 Replies View Related

How To Get A Value From SQLDataSource

May 28, 2007

Hi!Please tell me, how to get a simple value using SQLDataSource, I mean a number, or char, or string - any value, NOT DataTable 

View 3 Replies View Related

EOF With SqlDataSource

Jul 23, 2007

I am trying to get record from a table and verify it with a textbox i have a sqldatasource.
 i have a text box called txtEmail and this is my Select command. how can i get this working if its possible ?
something like txtEmail.text = SqlDataSource1.Secect then ... my code. (i dont know if this a correct way to do this)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacstestConnectionString %>"
SelectCommand="SELECT FROM [t_CustomerAcct]"
 
thanks,

View 1 Replies View Related

Something About Sqldatasource

Aug 13, 2007

hi all,i am using sqldatasource for gridviewso that i can edit and update any row at the same place ..... and not to write any code for that....now later on if i wanna change the selectcommand of that sqldatasource how can i ? so that the edit and update will be same as it was.... 

View 2 Replies View Related

Using An SQLDataSource For Than Once

Aug 21, 2007

Hi,
I'm trying to go through a checkbox list and inserting them into a database using a sqldatasource with the following code:For Each li As ListItem In Locations_Checkbox.Items
If li.Selected = True Then
 
Dim DataSource2 As SqlDataSource = CType(InsertProgrammeLocations, SqlDataSource) DataSource2.InsertParameters.Add("ProgrammeID", li.Value)
DataSource2.Insert()
 
 
End If
Next
When more than one checkbox is ticked, I'm getting the error 'The variable name '@ProgrammeID' has already been declared'. How do I close or reset my Datasource before I try and use it again?
Thanks for your help
  
 

View 3 Replies View Related

Sqldatasource

Oct 28, 2007

please explain selectparameter collection and conflict detection property and filterparameter
mohsen

View 1 Replies View Related

What Is SqlDataSource

Oct 29, 2007

Hi, I want to know when to use an sqlDataSource object because I used to populate for example a listBox control in visual studio net 2003 from AQLK server database by using a connection object, command object, dataAdapter object and a DataSet object. I discovered if I use sqlDataSource object (using visual studio net 2005) ,all I need is to write the connection string and a Select statement as properties for that sqlDataSource, so why to use the above mentioned objects(connection,command,adapter,dataset) while I can access any database in sql server through the use of sqlDataSource?
I appreciate if you can explain to me the difference and when to use an sqlDataSource
thx

View 1 Replies View Related

SqlDataSource

Dec 4, 2007

How can I update more than one table with one UpdateString in SqlDataSource?

View 5 Replies View Related

Do You Really Use SqlDataSource?

Dec 9, 2007

Hi,
I have an application w/ n-tier design so I've never used the SqlDataSource up to this point but having to do my own sorting for GridViews is not something I want to keep dealing with. I'd like to take advantage of some of the packaged features too.
My question is: are there any purists out there who opted to use SqlDataSource. If so, what do you think about it? It's nice that SqlDataSource makes things simple but having data classes and dealing w/ exceptions in those classes certainly make an application pretty robust. Should I entertain the idea of using SqlDataSource or stay as a purist and keep doing things the old fashioned way?

View 1 Replies View Related

Sqldatasource?

Dec 30, 2007

How to display returned data from sqldatasurce in a textbox.
This code is not working TextBox1.Text = SqlDataSource2.ToString(); Thanks Lot.

View 2 Replies View Related

SqlDataSource

Jan 16, 2008

Hey all,I've just started to use asp.net and so far have found it fairly easy. The only problem I've come across is with putting variable clauses into the SqlDataSources.This is one example of what I've done trying to get this to work. <asp:SqlDataSource ID="ClaimsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT TOP 20 dbo_ClaimStatus.ClaimStatus, dbo_CLAIMS.PACKET, dbo_INSURED.NAME, dbo_FEES.INSURER, dbo_FEES.CLAIM_NUMBER, dbo_CLAIMS.LOSS_DATE, dbo_CLAIMS.RECEIVED, dbo_CLAIMS.LOSS_LOCATION, dbo_CLAIM_TYPES.CODE FROM ( ( ( ( dbo_CLAIMS INNER JOIN dbo_CLAIM_TYPES ON dbo_CLAIMS.CLAIM_TYPE = dbo_CLAIM_TYPES.CODE ) INNER JOIN dbo_ClaimStatus ON dbo_CLAIMS.StatusID = dbo_ClaimStatus.ClaimStatusID ) INNER JOIN dbo_FEES ON dbo_CLAIMS.PACKET = dbo_FEES.PACKET ) INNER JOIN dbo_INSURED ON dbo_CLAIMS.PACKET = dbo_INSURED.PACKET ) WHERE dbo_ClaimStatus.ClaimStatus = @claimStatus"> <FilterParameters> <asp:QueryStringParameter Name="claimStatus" QueryStringField="ctl00$MainContent$claimStatus" /> </FilterParameters></asp:SqlDataSource>I'm posting claimStatus from a previous page using PostBackUrl on an <asp:Button /> tag and claimStatus is an <asp:DropDownList /> tag.Any idea's as to why this doesn't work?Nalum 

View 2 Replies View Related

SqlDataSource

Feb 24, 2008

Dear Friends in my project , i' ve used two SqlDataSource, one button and one gridview control;
the process that i want to do is when i click the button control ,according the  if structure in this button control ; one of the SqlDataSource control assign to the gridview control DataSource property (but i assign the DataSourceID property for the gridview , it runs);
but i couldnt do it, what can i do for it? (my code  doesnt give any errors but doesnt do anything too)
my code is here;
protected void btnSearch_Click(object sender, EventArgs e)     {         if (txtSearch.Text != null){             SqlDataSource3.SelectParameter["key"].DefaultValue = txtsearch.Text;             Gridview1.DataSource = SqlDataSource3;             GridView1.DataBind();         }         else         {             SqlDataSource1.SelectParameters["keySession"].DefaultValue = cbSession.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyClass"].DefaultValue = cbClass.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyUnit"].DefaultValue = cbUnit.SelectedItem.ToString();             Gridview2.DataSource = SqlDataSource1;             GridView2.DataBind();         }
 

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved