google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

DbMetal.exe gen sqlite dbml got error in vs2008 #216

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. DbMetal.exe --dbml=Test.dbml --provider=sqlite --conn="data
source=testing.sqlite"
success, no error.
But in vs2008 got 4 error, can't use.

What version of the product are you using? On what operating system?
DbLinq 0.19 on winXP, vs2008 pro

Please provide any additional information below.
Error   1   The type or namespace name 'sqlite' could not be found (are you
missing a using directive or an assembly reference?)    C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2008\Projects\test\Test.designer.cs 26  19  test
Error   2   Cannot implicitly convert type
'DbLinq.Data.Linq.Table<test.JobsTable>' to
'System.Data.Linq.Table<test.JobsTable>'    C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2008\Projects\test\Test.designer.cs 70  12  test
Error   3   Cannot implicitly convert type
'DbLinq.Data.Linq.Table<test.SettingTable>' to
'System.Data.Linq.Table<test.SettingTable>' C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2008\Projects\test\Test.designer.cs 78  12  test
Error   4   Cannot implicitly convert type
'DbLinq.Data.Linq.Table<test.SourceTable>' to
'System.Data.Linq.Table<test.SourceTable>'  C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2008\Projects\test\Test.designer.cs 86  12  test

attached the sqlite db file, thanks a lot

Original issue reported on code.google.com by alantang...@gmail.com on 19 Mar 2010 at 7:52

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I tried use "DbMetal.exe --namespace=test --code=sqlite.cs --provider=Sqlite
--conn="data source=testing.sqlite"" to gen a sqlite.cs, but when i run it,got 
error
 in "public Main(string connectionString): base(connectionString)"  ==> "Unable to
load the `DbLinq.SqlServer.dll' DbLinq vendor within assembly `SqlServer'. 
Parameter
name: connectionString"
when i add DbLinq.SqlServer.dll to references, will got another error "A
network-related or instance-specific error occurred while establishing a 
connection
to SQL Server. The server was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured to allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not open a 
connection
to SQL Server)" on DatabaseConnection's "_connection.Open();"(line: 59).

Original comment by alantang...@gmail.com on 19 Mar 2010 at 9:38

GoogleCodeExporter commented 9 years ago
I'm...confused.

The first command (`DbMetal /dbml:Test.dbml ...`) creates a .dbml file.  You 
then 
mention that VS2008 reports an error when loading this file, and that the 4 
errors 
are in Test.designer.cs.

I'm assuming that you just added the Test.dbml file to your project.

You can't do this, as .dbml files will be processed with the .NET SqlMetal.exe 
tool, 
not DbMetal, and thus will not have the appropriate DbLinq references.

For example, when I add the DbMetal-generated Test.dbml file, there are no 
'using' 
statements within Test.designer.cs for DbLinq.Data.Linq, and e.g. 
Main.JobsTable is 
of type 'System.Data.Linq.Table<JobsTable>'.  This won't work.

You need to use DbMetal to generate your Test.designer.cs file.

Comment #2 implies that you figured this out (as you mention that you can run 
it, 
implying that it built w/o error).

The problem you're hitting in Comment #2 is answered at:

    http://code.google.com/p/dblinq2007/wiki/Installation#at_Runtime

Specifically, if you're creating your DataContext using only the connection 
string, 
you need to provide BOTH DbLinqProvider AND DbLinqConnectionType key/value 
pairs in 
the connection string; otherwise DbLinq will assume you want to use SQL 
Server(hence 
the "Unable to load DbLinq.SqlServer" message).

You will also need to copy DbLinq.Sqlite.dll along with DbLinq.dll in order for 
your 
program to run.

Does this allow things to work for you?

Original comment by jonmpr...@gmail.com on 19 Mar 2010 at 2:29

GoogleCodeExporter commented 9 years ago
Oh!!! i understand now,the step is:
1. generate the test.dbml use:>DbMetal.exe --conn="data source=testing.sqlite"
--provider=sqlite --dbml=test.dbml
2. generate the code file test.designer.cs use:>DbMetal.exe --conn="data
source=testing.sqlite" --provider=sqlite --code=test.designer.cs
3. add the dbml to vs2008.
4. copy the test.designer.cs code replace vs2008's code.
5. the make the instance use SqliteDataContext sqliteDC = new 
SqliteDataContext(new
SQLiteConnection("Data Source=testing.sqlite"))

i success to insert a record to sqlite now, thank you very much ^_^

Original comment by alantang...@gmail.com on 19 Mar 2010 at 3:51

GoogleCodeExporter commented 9 years ago
Step 1 isn't necessary.

Alternatively, if you want/need a .dbml file, then you can alter Step 2 to be:

    DbMetal /code:Test.designer.cs test.dbml

If you skip step 1, then step 3 isn't necessary (again, depending on whether 
you 
actually want/need a .dbml file).

That said, it looks like things are working for you.  Closing.

Original comment by jonmpr...@gmail.com on 19 Mar 2010 at 5:08

GoogleCodeExporter commented 9 years ago
i see. because i read a book talking about linq to sql the easy way is create a 
dbml
file, so i don't really understand what i need... until i see your comment 5, 
use
dbmetal generate code = dbml's code behide.

Many thanks ^_^

Original comment by alantang...@gmail.com on 19 Mar 2010 at 5:15

GoogleCodeExporter commented 9 years ago
Any feedback on 
http://code.google.com/p/dblinq2007/wiki/VisualStudioAndDbmlFiles 
would be appreciated.

Thanks!

Original comment by jonmpr...@gmail.com on 23 Mar 2010 at 6:50