Why my string variable can't be assigned with a value 
Author Message
 Why my string variable can't be assigned with a value

Hi,

I've got a strange situation here.

I've declared a string variable as a Private in my COM for my constructor

However, nothing can be assigned to the string varaible. Its always
"Nothing".

Anyone has any idea why is this so?

Thanks.
YL



Sat, 27 Aug 2005 11:56:48 GMT  
 Why my string variable can't be assigned with a value
code?


Quote:
> Hi,

> I've got a strange situation here.

> I've declared a string variable as a Private in my COM for my constructor

> However, nothing can be assigned to the string varaible. Its always
> "Nothing".

> Anyone has any idea why is this so?

> Thanks.
> YL



Sat, 27 Aug 2005 14:58:03 GMT  
 Why my string variable can't be assigned with a value
it goes something like this

<Transaction(TransactionOption.Required)> _

Public Class Class1

Inherits ServicedComponent

Private strConn As String

Private objConn As SqlConnection

Public Sub New()

Try

objConn = New SqlConnection()

strConn = "server=abc;uid=abc;pwd=abc;database=testdb"

objConn.ConnectionString = strConn

objConn.Open()

Catch ex As Exception

SetErr = ex.Message & " : " & strConn

objConn = Nothing

End Try

End Sub

thank you !

"Dominique Vandens{*filter*}" <dominique.vandens{*filter*}_herecomesat_acunia.com> wrote

Quote:
> code?



> > Hi,

> > I've got a strange situation here.

> > I've declared a string variable as a Private in my COM for my
constructor

> > However, nothing can be assigned to the string varaible. Its always
> > "Nothing".

> > Anyone has any idea why is this so?

> > Thanks.
> > YL



Sat, 27 Aug 2005 15:21:00 GMT  
 Why my string variable can't be assigned with a value
If your code fails on the line "objConn = New SqlConnection()" then the
string will never have a value set in it.

Cheers,
  Jason

it goes something like this

<Transaction(TransactionOption.Required)> _

Public Class Class1

Inherits ServicedComponent

Private strConn As String

Private objConn As SqlConnection

Public Sub New()

Try

objConn = New SqlConnection()

strConn = "server=abc;uid=abc;pwd=abc;database=testdb"

objConn.ConnectionString = strConn

objConn.Open()

Catch ex As Exception

SetErr = ex.Message & " : " & strConn

objConn = Nothing

End Try

End Sub

thank you !

"Dominique Vandens{*filter*}" <dominique.vandens{*filter*}_herecomesat_acunia.com>
wrote

Quote:
> code?



> > Hi,

> > I've got a strange situation here.

> > I've declared a string variable as a Private in my COM for my
constructor

> > However, nothing can be assigned to the string varaible. Its always
> > "Nothing".

> > Anyone has any idea why is this so?

> > Thanks.
> > YL



Sat, 27 Aug 2005 21:54:53 GMT  
 Why my string variable can't be assigned with a value
yes, as i stepped through my program, the code fails on the line "objConn =
New SqlConnection()".
Why is this so? I've got this exception error as well  "Exception from
HRESULT: 0x8004D00E"  any idea why?

thanks

Cheers,
YL



Quote:
> If your code fails on the line "objConn = New SqlConnection()" then the
> string will never have a value set in it.

> Cheers,
>   Jason


> it goes something like this

> <Transaction(TransactionOption.Required)> _

> Public Class Class1

> Inherits ServicedComponent

> Private strConn As String

> Private objConn As SqlConnection

> Public Sub New()

> Try

> objConn = New SqlConnection()

> strConn = "server=abc;uid=abc;pwd=abc;database=testdb"

> objConn.ConnectionString = strConn

> objConn.Open()

> Catch ex As Exception

> SetErr = ex.Message & " : " & strConn

> objConn = Nothing

> End Try

> End Sub

> thank you !

> "Dominique Vandens{*filter*}" <dominique.vandens{*filter*}_herecomesat_acunia.com>
> wrote

> > code?



> > > Hi,

> > > I've got a strange situation here.

> > > I've declared a string variable as a Private in my COM for my
> constructor

> > > However, nothing can be assigned to the string varaible. Its always
> > > "Nothing".

> > > Anyone has any idea why is this so?

> > > Thanks.
> > > YL



Sun, 28 Aug 2005 10:02:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. CAN'T ASSIGN A NULL VALUE TO A VARIABLE

2. Cannot assign a variable declared as a string to a variable declared as data type

3. Assigning the value to the value of a variable

4. The value of a variable (String type) is the name of a variable

5. Assign an 'onClick' value

6. Null Values - WHY am I getting this error?

7. Assign a value to a variable using Select

8. ACC 97: Assign values to variables

9. Decimal precision when assigning values to variables

10. Assigning the value of a variable to a control in Vba

11. Assign variable a value in a table with vba, acc97

12. Assigning a value from a list box to a variable

 

 
Powered by phpBB® Forum Software