Home All Groups Group Topic Archive Search About
Author
30 May 2006 4:10 PM
Wendy Elizabeth
I am writing a vb.net program that needs to create a table in the same format
each time it creates a new table. This is a "ulility" program that I am going
to be using it for.
  Right now I have keyed this large table into sql server 2000 and the
vb.net program I wrote loads all the columns appropriately. I have run sql
server 2000 with the "generate script" for me have have saved the sql server
2000 code that will create a table.

The start of the script looks like
"CREATE TABLE [dbo].[test_table] ([field1] [varchar] (40) COLLATE
SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[field] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

The end of the table looks like:
[WC_USE.22] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,[WC_PASSWORD.20] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , {
[MPLANNER] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

I would like to incorporate this code into the VB.net program. To to this I
need to put " (quotes) at the start of every line and I need to put  "  & _
at the end of every line.

Is there a way to have this completed for me without having to key this in
on every line? This would be similar to the "comment select lines" and
"uncomment selected lines" feature that the visual studio .net ide has.

Thanks!

Author
30 May 2006 4:49 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Wendy Elizabeth" <WendyElizab***@discussions.microsoft.com> schrieb:
>I am writing a vb.net program that needs to create a table in the same
>format
> each time it creates a new table. This is a "ulility" program that I am
> going
> to be using it for.
>  Right now I have keyed this large table into sql server 2000 and the
> vb.net program I wrote loads all the columns appropriately. I have run sql
> server 2000 with the "generate script" for me have have saved the sql
> server
> 2000 code that will create a table.
>
> The start of the script looks like
> "CREATE TABLE [dbo].[test_table] ([field1] [varchar] (40) COLLATE
> SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [field] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
>
> The end of the table looks like:
> [WC_USE.22] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,[WC_PASSWORD.20] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> , {
> [MPLANNER] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
>
> I would like to incorporate this code into the VB.net program. To to this
> I
> need to put " (quotes) at the start of every line and I need to put  "  &
> _
> at the end of every line.

If you are using VB 2005, choose "My Project" in the solution explorer,
click "Resources", add a new string resource, name it 'CommandStringStart',
and paste the start string into the resource.  Then do the same for the end
string.  Inside the source code you can refer to the strings as shown below:

\\\
Dim CommandString As String = _
    My.Resources.CommandStringStart & _
    ... & _
    My.Resources.CommandStringEnd
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
30 May 2006 6:20 PM
Wendy Elizabeth
Herfried K. Wagner:

  Thank you for answering my question. However, I should have mentioned that
I am using Visual studio.net 1.1 (2003 version). Can you tell me how I would
accomplish this task using Visual studio.net 1.1 instead?

  Thanks!

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Wendy Elizabeth" <WendyElizab***@discussions.microsoft.com> schrieb:
> >I am writing a vb.net program that needs to create a table in the same
> >format
> > each time it creates a new table. This is a "ulility" program that I am
> > going
> > to be using it for.
> >  Right now I have keyed this large table into sql server 2000 and the
> > vb.net program I wrote loads all the columns appropriately. I have run sql
> > server 2000 with the "generate script" for me have have saved the sql
> > server
> > 2000 code that will create a table.
> >
> > The start of the script looks like
> > "CREATE TABLE [dbo].[test_table] ([field1] [varchar] (40) COLLATE
> > SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> > [field] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> >
> > The end of the table looks like:
> > [WC_USE.22] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> > ,[WC_PASSWORD.20] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> > , {
> > [MPLANNER] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> > ) ON [PRIMARY]
> >
> > I would like to incorporate this code into the VB.net program. To to this
> > I
> > need to put " (quotes) at the start of every line and I need to put  "  &
> > _
> > at the end of every line.
>
> If you are using VB 2005, choose "My Project" in the solution explorer,
> click "Resources", add a new string resource, name it 'CommandStringStart',
> and paste the start string into the resource.  Then do the same for the end
> string.  Inside the source code you can refer to the strings as shown below:
>
> \\\
> Dim CommandString As String = _
>     My.Resources.CommandStringStart & _
>     ... & _
>     My.Resources.CommandStringEnd
> ///
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
>
Author
31 May 2006 10:54 AM
NickP
Hi Wendy,

    Use the following function to obtain a byte array from a resource,
remember that you need to include the namespace in the key.  Use reflector
to find the correct name from the compiled exe...

Public Shared Function resourceToByteArray(ByVal iAssembly As [Assembly],
ByVal iKey As String) As Byte()
    Dim pStmInput As Stream = iAssembly.GetManifestResourceStream(iKey)
    If (pStmInput Is Nothing) Then
        Throw New Exception("Resource '" & iKey & "' was not found in
assembly '" & iAssembly.ToString & "'.")
    Else
        Dim pBytBuffer(CInt(pStmInput.Length - 1)) As Byte
        Call pStmInput.Read(pBytBuffer, 0, CInt(pStmInput.Length))
        Call pStmInput.Close()
        Return (pBytBuffer)
    End If
End Function

    You can then use Text.Encoding.<Encoder>.GetString() to obtain a string
from whatever format the initial text file was in...

Nick.

Show quoteHide quote
"Wendy Elizabeth" <WendyElizab***@discussions.microsoft.com> wrote in
message news:2DB48CD7-F7F9-40C8-829F-04B68D0A796C@microsoft.com...
> Herfried K. Wagner:
>
>  Thank you for answering my question. However, I should have mentioned
> that
> I am using Visual studio.net 1.1 (2003 version). Can you tell me how I
> would
> accomplish this task using Visual studio.net 1.1 instead?
>
>  Thanks!
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> "Wendy Elizabeth" <WendyElizab***@discussions.microsoft.com> schrieb:
>> >I am writing a vb.net program that needs to create a table in the same
>> >format
>> > each time it creates a new table. This is a "ulility" program that I am
>> > going
>> > to be using it for.
>> >  Right now I have keyed this large table into sql server 2000 and the
>> > vb.net program I wrote loads all the columns appropriately. I have run
>> > sql
>> > server 2000 with the "generate script" for me have have saved the sql
>> > server
>> > 2000 code that will create a table.
>> >
>> > The start of the script looks like
>> > "CREATE TABLE [dbo].[test_table] ([field1] [varchar] (40) COLLATE
>> > SQL_Latin1_General_CP1_CI_AS NOT NULL ,
>> > [field] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
>> >
>> > The end of the table looks like:
>> > [WC_USE.22] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
>> > ,[WC_PASSWORD.20] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS
>> > NULL
>> > , {
>> > [MPLANNER] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
>> > ) ON [PRIMARY]
>> >
>> > I would like to incorporate this code into the VB.net program. To to
>> > this
>> > I
>> > need to put " (quotes) at the start of every line and I need to put  "
>> > &
>> > _
>> > at the end of every line.
>>
>> If you are using VB 2005, choose "My Project" in the solution explorer,
>> click "Resources", add a new string resource, name it
>> 'CommandStringStart',
>> and paste the start string into the resource.  Then do the same for the
>> end
>> string.  Inside the source code you can refer to the strings as shown
>> below:
>>
>> \\\
>> Dim CommandString As String = _
>>     My.Resources.CommandStringStart & _
>>     ... & _
>>     My.Resources.CommandStringEnd
>> ///
>>
>> --
>>  M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>>  V B   <URL:http://classicvb.org/petition/>
>>
>>