Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

DataGrid+Ado.net  problem...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Surendra - 07 Dec 2004 13:39 GMT
Hi to all techies,
I want to build DB application using Datagrid.
I written one function for this.
But it is giving error like on this line
"Dim cnNorthwind As SqlConnection = New SqlConnection(cString)"

"An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: Keyword not supported: 'use procedure for prepare'."

-------------
Function code is as follows
   Private Sub ConnectToData()
       ' Create the ConnectionString and create a SqlConnection.
       ' Change the data source value to the name of your computer.
       Dim cString As String = "Persist Security Info=False;User
ID=tcoc;Initial Catalog=Northwind;Data Source=DEVSQLSEWRI;Use Procedure for
Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SEWR110;"
       Dim cnNorthwind As SqlConnection = New SqlConnection(cString)
       'cnNorthwind.ConnectionString = cString
       ' Create a SqlDataAdapter for the Suppliers table.
       Dim adpSuppliers As SqlDataAdapter = New SqlDataAdapter
       ' A table mapping tells the adapter what to call the table.
       adpSuppliers.TableMappings.Add("Suppliers", "Suppliers")
       cnNorthwind.Open()
       Dim cmdSuppliers As SqlCommand = _
       New SqlCommand("SELECT * FROM Suppliers", cnNorthwind)
       cmdSuppliers.CommandType = CommandType.Text

       adpSuppliers.SelectCommand = cmdSuppliers
       Console.WriteLine("The connection is open.")
       ds = New DataSet("Customers")
       adpSuppliers.Fill(ds)
       ' Create a second SqlDataAdapter and SqlCommand to get
       ' the Products table, a child table of Suppliers.
       Dim adpProducts As SqlDataAdapter = New SqlDataAdapter
       adpProducts.TableMappings.Add("Table", "Products")
       Dim cmdProducts As SqlCommand = _
       New SqlCommand("SELECT * FROM Products", cnNorthwind)
       adpProducts.SelectCommand = cmdProducts
       adpProducts.Fill(ds)
       cnNorthwind.Close()
       Console.WriteLine("The connection is closed.")
       ' You must create a DataRelation to link the two tables.
       Dim dr As DataRelation
       Dim dc1 As DataColumn
       Dim dc2 As DataColumn
       ' Get the parent and child columns of the two tables.
       dc1 = ds.Tables("Suppliers").Columns("SupplierID")
       dc2 = ds.Tables("Products").Columns("SupplierID")
       dr = New System.Data.DataRelation("suppliers2products", dc1, dc2)
       ds.Relations.Add(dr)
   End Sub
End Class
---------------------------
plz, hepl me.
bye & thank u in advance
Clamps - 07 Dec 2004 18:03 GMT
Get rid of the 'use procedure for prepare=1' from your connection string.

| Hi to all techies,
| I want to build DB application using Datagrid.
[quoted text clipped - 53 lines]
| plz, hepl me.
| bye & thank u in advance

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.