Solved

DataAdpater

Posted on 2006-07-21
2
186 Views
Last Modified: 2010-04-17
In attempt to get away from using the DataAdapter Wizard - it's causing problems with the connection the we are using.  I need to hand code in the adpaters.  I'm looking for a good example of one that is using a stored procedure that needs a parameter or multiple parameters.

Any help would be appreciated.

my connectionstring is using the app.config file (example)

'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = AppSettings.Get("ABRConn")


When using the wizard this string can not be selected and if the connection string in the adpater is changed with the wizard it removes the above code.


thanks in advance.


0
Comment
Question by:TimSweet220
2 Comments
 
LVL 14

Accepted Solution

by:
shahprabal earned 400 total points
ID: 17157834
Dim myConn As OleDbConnection = New OleDbConnection _
   ( "Provider=SQLOLEDB; Data Source=localhost; " & _
   "Integrated Security=SSPI; Initial Catalog=northwind" )
Dim salesCmd As OleDbCommand = New OleDbCommand _
   ( "SalesByCategory", myConn )
salesCmd.CommandType = CommandType.StoredProcedure

Dim myParam As OleDbParameter = salesCmd.Parameters.Add _
   ( "@CategoryName", OleDbType.NVarChar, 15 )
myParam.Value = "Beverages"

myConn.Open ( )
Dim myReader As OleDbDataReader = salesCmd.ExecuteReader ( )
Response.Write ( myReader.GetName ( 0 ) & ", " & _
   myReader.GetName ( 1 ) & "<br>" )

Do While myReader.Read ( )
   Response.Write ( myReader.GetString ( 0 ) & ", " & _
      myReader.GetDecimal ( 1 ) & "<br>" )
Loop

myReader.Close ( )
myConn.Close ( )
0
 
LVL 2

Assisted Solution

by:JohnWoo
JohnWoo earned 100 total points
ID: 17159902
You may want to put your connection string into an external text file instead of into the config file. Then u retrieve it everytime when your system runs by reading that file.

next you can write out your stored procedure in SQL server. You can refer to the following link on how to pass parameter into the stored procedure you have written:

http://www.codeproject.com/dotnet/NET_Data_Access.asp
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 88
Excel object stays open 19 65
sumDigits  challenge 7 60
Image decoding from Camera 3 45
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now