Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

couple of super newbe questions. how to continue to next line in code 1

Status
Not open for further replies.

seminewbee2005

Instructor
Jun 5, 2005
60
US
my code of line is too long, what character or doohicky do I need to type to tell vb.net code window I am continuing this statement on the next line.?


2. a. I was told not have have my queries i write from vb.net apps to sql server be sql statements. rather encapsulated stored procedue. But I am a little foggy on how this help ntwoek traffic. What is causing the extra bandwidth my actuall statement?

Select Entertainer, Agent, Age, PersonalHobbies
From Agent
Where Age < 25

2. b. how would I encapsulate this select statement?
specify the stored procedure by name and give it parameter?

name: SP_SQL_Select_Agent parameter: age < 25

truly you can see my newbeeism here. Anyone have any exact example of how I would encapsulate such a stored procedure call in vb.net and send to sql server for execution?
 
1. The underscore:

If a = 1 and b = 2 and c = 3 _
and d = 4 and e = 5 Then

Note: there has to be a space before the underscore, and you cannot break a line in the middle of a word. There are some other limitations, but you should be able to figure them out now.

2.a. It's not the extra bandwidth - which is insignificant - its that a stored procedure is pre-compiled on the server, whereas a SQL statement you send is has to be checked, validated, evaluated, etc. This takes time, and will cause a major performance hit if the query is complex.

2.b. If you are selecting into a DataAdapter, create a SqlCommand object and pass the SqlCommand as a parameter to the DataAdapter's constructor:

Dim conn as SqlConnection
Dim da as SQLDataAdapter
Dim cmd As SqlCommand

conn = New SqlConnection("<some connection string>")

conn.Open()

cmd = New SqlCommand("SP_SQL_Select_Agent", conn)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("Age", SqlDbType.Int, 4)

cmd.Parameters("Age").Value = 25

da = New SqlDataAdapter(cmd)


Look up the SqlCommand object in MSDN. You will probably need to play around with the parameters of the Parameters.Add method to get it to work right.

Hope this helps.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top