Showing posts with label helloi. Show all posts
Showing posts with label helloi. Show all posts

Sunday, March 11, 2012

Creating a Mobile Application with SQL Server Compact Edition

Hello!!

I completed that example that I pasted in the subject part and when I try to synchronize my mobile database, the data from the server appear in my pocket pc; but when i refresh the data on my pocket pc they do not show on the server.

Can anyone give me a hand?

thanks

This sample is a download only scenario. Are you still running this code in form_Load ?:

Code Snippet

private void Form1_Load(object sender, EventArgs e)
{
DeleteDB();
Sync();

// TODO: Delete this line of code.
this.flightDataTableAdapter.Fill(this.sqlmobileDataSet.FlightData);
// TODO: Delete this line of code.
this.membershipDataTableAdapter.Fill(this.sqlmobileDataSet.MembershipData);
}

This sample allows two way sync: http://technet.microsoft.com/en-us/library/ms346580.aspx

and so does this Hands On Lab: http://msdn2.microsoft.com/en-us/library/aa454892.aspx

|||

I will try to make those example.

Thank you very much.

Wednesday, March 7, 2012

creating a FK on existing tables

hello
I am working with an existing database and there is no Foreign key between 2 tables
how can i create a FK after , when the tables are allready full ?

product :

product_id
report_id
name

report :

report_id
dateR

i want to create a FK on product.report_id, and ON DELETE CASCADE

thank you--Creating table with same structure (Primary key)]
CREATE TABLE [A] (
[report_id] [varchar] (10) ,
[dateR] [Datetime],
CONSTRAINT [PK_A] PRIMARY KEY CLUSTERED
(
[report_id]
) ON [PRIMARY]
) ON [PRIMARY]
GO
--Inserting data from report table
INSERT INTO A
SELECT * FROM report

--Dropping table report
DROP TABLE report
GO
--Renaming A table as report table
EXEC sp_rename 'A','report'
GO
--Caution: Changing any part of an object name
--could break scripts and stored procedures.

--This will create a FK in product table

ALTER TABLE products WITH NOCHECK
ADD CONSTRAINT exd_check FOREIGN KEY
(
[report_id]
) REFERENCES [report] (
[report_id]
) ON DELETE CASCADE|||genial !

thanks a lot

Tuesday, February 14, 2012

create view using data in seperate severs

Hello:

I'd like to create a view on server x which references tables on an

entirely seperate server. Is this possible? Is seems

strange to have to copy the tables over just to create a view. In

the view wizard I can't seem to 'browse' to the tables on the other

server.

The code I'm working with would conceptually be something like this:

select server name.database instance.owner.table.field

from server name.database instance.owner.table

where <field name> like 'xxxx%'

or something along those lines.

Any help would be appreciated!

Thanks.Thats right, you will not be able to browse for them. If you use SQL Server 2005, you can first create synonyms which are browsable in the designer or use the four part name syntax which will make them accessible for the designer to pull your joins together (if you want to). So Doing something like this:

Select * from LinkedServer.DatabaseName.SchemaOrOwner.ObjectName

will bring you the linked object in the design view.

HTH; Jens K. Suessmeyer.

http://www.sqlserver2005.de|||I'm using SQL 2000.

Below is the conceptual code. I continue to get errors with this approach.

SELECT *

FROM servertable.databaseinstance.owner.table INNER JOIN


servertable.databaseinstance.owner.table ON

databaseinstance.owner.table.field = databaseinstance.owner.table.field

INNER JOIN


servertable.databaseinstance.owner.table ON

databaseinstance.owner.table.field = databaseinstance.owner.table.field

INNER JOIN


servertable.databaseinstance.owner.table ON

databaseinstance.owner.table.field = databaseinstance.owner.table.field

INNER JOIN


servertable.databaseinstance.owner.table ON

databaseinstance.owner.table.field = databaseinstance.owner.table.field

Any thoughts on what I might be doing wrong? The server is a linked server. The tables have select permission.

Thanks.|||

I don′t know what servertable means, but it should be something like this here (using Aliases) which makes reading more straight forward.

SELECT * From
SomeLocalTable LT
INNER Join LinkedServername.databasename.owner.table LST
ON LST.Col1 = LT.Col1
(...and so on...)


HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

kubmg wrote:

I'm using SQL 2000.

Below is the conceptual code. I continue to get errors with this approach.

SELECT *
FROM servertable.databaseinstance.owner.table INNER JOIN
servertable.databaseinstance.owner.table ON databaseinstance.owner.table.field = databaseinstance.owner.table.field INNER JOIN
servertable.databaseinstance.owner.table ON databaseinstance.owner.table.field = databaseinstance.owner.table.field INNER JOIN
servertable.databaseinstance.owner.table ON databaseinstance.owner.table.field = databaseinstance.owner.table.field INNER JOIN
servertable.databaseinstance.owner.table ON databaseinstance.owner.table.field = databaseinstance.owner.table.field

Any thoughts on what I might be doing wrong? The server is a linked server. The tables have select permission.

Thanks.

kindly post the error your getting

|||BTW, servertable is the server name, sorry.

When I run the above code I get the following error:

Server: Msg 117, Level 15, State 2, Line 3

The number name 'servername.databaseinstance.owner.table' contains more than the maximum number of prefixes. The maximum is 3.

If I run a simplified query like below I get returned values:

select *

from servername.databaseinstance.owner.table

where field = 'xxxxxxxx'

If I add to the select query the following (which I would like to do in the view), I get the following:

select servername.databaseinstance.owner.table.fieldname

from servername.databaseinstance.owner.table

where field = 'xxxxxxxx'

Server: Msg 117, Level 15, State 2, Line 1

The number name 'servername.databaseinstance.owner.table' contains more than the maximum number of prefixes. The maximum is 3.

The joining that occurs on the tables were defined in the view

design. I suppose they are correct as I do get valid

results.|||

Hi,

select servername.databaseinstance.owner.table.fieldname
from servername.databaseinstance.owner.table
where field = 'xxxxxxxx'

Why don′t you use an alias here or no alias, as you don′t use the full declaration in where part either.

select fieldname
from servername.databaseinstance.owner.table
where field = 'xxxxxxxx'

Or

select t1.fieldname
from servername.databaseinstance.owner.table t1
where t1.field = 'xxxxxxxx'

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de