Showing posts with label schema. Show all posts
Showing posts with label schema. Show all posts

Friday, February 24, 2012

Obtain sqlceresultset table schema with GetSchemaTable

I have a SqlCeResult pointing to a table :

Public conexion As Data.SqlServerCe.SqlCeConnection = New Data.SqlServerCe.SqlCeConnection("Data Source=iPAQ File Store\GestionAlmacenN.sdf")

Public ComandoCargaProductos As Data.SqlServerCe.SqlCeCommand = conexion.CreateCommand

Public ResultSetProductos As Data.SqlServerCe.SqlCeResultSet

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

conexion.Open()

'**********************************************************

'************Conexion con Tabla Productos******************

'ComandoCargaProductos.CommandText = "SELECT * from [Productos]"

ComandoCargaProductos.CommandType = Data.CommandType.TableDirect

ComandoCargaProductos.IndexName = "PK__Productos__0000000000000041"

ComandoCargaProductos.CommandText = "Productos"

ResultSetProductos = ComandoCargaProductos.ExecuteResultSet(Data.SqlServerCe.ResultSetOptions.Scrollable Or Data.SqlServerCe.ResultSetOptions.Updatable)

End Sub

And I want to obtain the schema of the table which my resultset is pointing

Dim tabla As Data.DataTable

tabla = Me.ResultSetProductos.GetSchemaTable

But the datatable that i obtain don′t seem to have the schema that i need, for example don′t have the primary keys i have define and also don′t have any constrains......

Does anybody know the problem?

Thanks for your help

To get contraints like primary key, you can use IsUnique and IsKey property which you get in SchemaTable. To get the contraints you can get by querying the INFORMATION_SCHEMA.TABLE_CONSTRAINTS. Get more help at http://msdn2.microsoft.com/en-us/library/ms181757.aspx

Monday, February 20, 2012

Objects cannot be created by using Transact-SQL statement

I can create a database or table or schema by using the (right click) context menu. This method is successful.

When I use the Transact-SQL statement (query window) to create an object, after being executed the reply is: command(s) completed successfully. However, the object does not get created.

Has anyone else had this issue? Any ideas?

We are using the MSSQL 2005 Enterprise server eval edition.

Thanks for your help.

Did you try to create an object in the schema and check again ? :-)

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||Please check the Database name (Available Database - Combobox), it may creates your object on some other (or on default) database..|||Where did you create the object? What was your selected database when you ran the script?

Also, Enterprise Mgr doesn't refresh the screen. You need to refresh the screen to get new objects to show up.|||

Tom Phillips wrote:

Where did you create the object? What was your selected database when you ran the script?

Also, Enterprise Mgr doesn't refresh the screen. You need to refresh the screen to get new objects to show up.

Just to add, simply highlight the database in a management suite, right click it and choose refresh... if you have created a stored procedure or a view, highlighting the appropriate node and right clicking, choosing refresh does a good job also.

hth
Barry|||

Thank you for all responses. My problem was resolved. I realized that I had to add a local user to my server before creating the new user in MS SQL Server. After that I could grant the permission to the database. Now everything is working smoothly.

Thanks again,

Yui