Showing posts with label everyonei. Show all posts
Showing posts with label everyonei. Show all posts

Sunday, March 11, 2012

a SqlDataSource can execute two InsertCommand?

hi everyone

i have a SqlDataSource
and i want execute two T-Sql (two InsertCommand)
but not success
How did i do this?

Thanks

1 Protected Sub SqlDataSource1_Inserted(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)Handles SqlDataSource1.Inserted
2 Dim SDSTempAs SqlDataSource =Nothing
3 Try
4 SDSTemp =New SqlDataSource(CnStr,"")
5 SDSTemp.InsertCommandType = SqlDataSourceCommandType.Text
6 SDSTemp.InsertCommand ="INSERT INTO Table1 (id,t1,t2) VALUES (@.id,@.t1,@.t2)"
7 Dim idAs String = e.Command.Parameters("@.id").Value.ToString
8 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 exAs Exception
19 Message.Text = ex.Message.ToString
20 End Try
21 End Sub
22

you can use the ItemCommand Event and place your code in there. Here is a reference you can use:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.itemcommand.aspx

The following link shows an quick example I made to help ya out some more also:http://forums.asp.net/thread/1692239.aspx

Hope this helps.

Thursday, March 8, 2012

A simple question on the connection string format on sql server 2005!

Hi everyone!
I am new to visual studio 2005 and sql server 2005.
Up to now i was using visual studio 2003 and ms access.

When i wanted to create a web application that communicates withan access database, i just had to take the *.mdb file and put itinto a specific folder inside my application's folder and then useServer.MapPath on the connection string (so it can run on any pc).

Now, i want to do the same with sql server 2005 and visual studio 2005.I use the connection string: "Server=MYSERVER;InitialCatalog=test_db;Integrated Security=SSPI".

My problems are:
1) Can i just take the *.mdf file put it inside the App_Data folder like i did on access?
2) What should be the connection string so that my application can run on any pc (with sql server 2005)?

Thanx in advance guys!Right click the app_data folder in solution explorer, say add new item. Choose the SQL Database, give it a name, and click ok. Drop a sqldatasource on a form, and choose the correct connection string from the dropdown, and when it asks if you want to put the connection string in web.config, say yes.

A simple question

Hello, everyone:
I do need help for a simple qustion. Does any one give the summary for server-side and client-side tools? What do they include?
Thanks a lot.
Yitongserver side tools
enterprise manager
query analyzer
profiler
import export wizard (DTS)
server network utitilty
about a gazilion wizards.

client side tools
query analyzer
client network utiltiy

probably my favorite and most underrated tool has to be the "Web Assistant Wizard" that's just cool on so many different levels.

BOOKS ONLINE Both
[BOL] Management Tools; Query Tools; Using the Web Assistant Wizard

if you clarify i could add more|||Hi, Scott:

Thanks a lot. I am confused about concept. Should the client-side include tool include applications?

ZYT|||Ruprect to you

i think that you could include that here
i was just menitoning the ones provided with sql server