I need to create a foreign key like the code below:
Create.ForeignKey().FromTable("TCGDocFiscalOpMedItem").ForeignColumn("IDCabecalhoDocFiscal","NumeroItem").ToTable("TCGDocFiscalItem").PrimaryColumn("IDCabecalhoDocFiscal","NumeroItem");
Obviously this code does not work.
How can I do something like these?
thanks
I found the answer, simply use ForeignColumns() with S at the end instead ForeignColumn().
thanks guys
Related
I can find the list of indexes for a table by using the following:
PRAGMA index_list(myTable);
From the results of this, I can get details about the columns within an index with the following:
PRAGMA index_info(myIndex);
But I cannot seem to find a way to tell the columns sort order. Is there another pragma that I have overlooked that can let me do this?
Note: I know that I can select from SQLITE_MASTER and parse the sort order out of the create statement, but I would prefer to stay out of parsing if possible. However if this is the only solution, then it will have to work.
After a quick grep through the 3.7.13 source code, I don't believe the sort order is exposed by any of the pragmas. The only references to KeyInfo::aSortOrder that I can find are either in the CREATE INDEX code, or in actual database operations like querying or comparing indices with one another.
It doesn't look like it would be a lot of work to add it to the index_info pragma, if doing a custom build of SQLite is an option for you.
I'm trying to get a single value from my table in a database. They are all given a unique id when stored. Here is the code I use to put the in:
With SqlDataSource1
.InsertParameters("page").DefaultValue = ViewState("TrueURL")
If My.User.IsAuthenticated Then
.InsertParameters("sender").DefaultValue = My.User.Name
Else
.InsertParameters("sender").DefaultValue = Request.UserHostAddress.ToString
End If
.InsertParameters("details").DefaultValue = PrepareText(TextBox2.Text)
.InsertParameters("date").DefaultValue = Now()
.Insert()
End With
That was so you could get an idea of what I was looking for, I'm not looking for sql statements, I don't know how to use them.
Just keep in mind, this is all vb.net/asp.net.
Thanks!
--EDIT--
I think I found something useful but I can't find how to use it. The Select function. It returns something and accepts parameters like the insert one I mentioned above... any ideas?
You cant extract it without first running an SQL query to extract it.
If you've got this far, read a little further in the MS help pages about how to run the select querys, this is where you would put your SQL statements.
Are there any commands that make life easy with respect to this? I want to take the column schema of one datatable (.net datatable) and copy it to another new datatable.
I've seen something like:
SELECT * INTO [DestinationTable] FROM [SourceTable] WHERE (1=2);
Used in SqlServer.
I think this assumes that DestinationTable doesn't exist. It then creates the table and copies the schema from SourceTable the WHERE clause prevents any actual data from being copied.
I'm not really a database developer, so there's probably a much better way to do this.
I've found the answer. It is the .Clone method.
Is there a general consensus on how to use SQL 2005's full text search with SubSonic? I know that I can use the InlineQuery and get an IDataReader, but is this the only way to do this? Also, how would I incorporate paging into it? Would I have to write the paging myself in the InlineQuery?
What I would really like to do is something like this:
new Select().From<Item>().Where("FreeText(Title, #title)").ExecuteAsCollection<ItemCollection>();
This way, I can use the built-in Subsonic paging functions and not have to write the entire query in SQL
This is one case with SubSonic where I think it is easier to create a stored procedure and build the collection from the result. Paging in a sproc isn't that difficult to implement (capture the sql generated by SubSonic and reuse it).
You can build a typed collection from the sproc by passing SPs.SPNameHere.GetReader() to the ItemCollection.Load() method. Make sure the sproc returns what a SELECT * FROM Item would return.
This won't work with SubSonic as it is now. I made a patch a while ago that would do something like this but it never got in. I'm wondering if it should be their or not what do you think?
Using VB.NET, how do I add the values from an XML file into an SQL Server database with a similar schema?
I don't know the methods off the top of my head but you ought to be able to load the file into a DataTable and then use ADO.net to get it into the database (look into the SqlBulkCopy class if you're using a SQL Server DB).
This ought to get you enough words to punch into and find a good example.
Easiest way is using the DataSet class's ReadXml() method. Then, as the user above mentions, the dataset contains one (1) DataTable. It's pretty easy to get that into SQL.
Use an XSL Transform to create an insert statement.
can't use xsl transform, you need a string for query, not another xml