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