Showing posts with label standard. Show all posts
Showing posts with label standard. Show all posts

Monday, March 19, 2012

DataReader not reading

Why won't this dataReader read?

Dim objCon2 As New SqlConnection()
objCon2.ConnectionString = "a standard connection string"
objCon2.Open()

Dim objCommand As SqlCommand
objCommand = New SqlCommand(strSQL, objCon2)
Dim objReader As SqlDataReader
objReader = objCommand.ExecuteReader()

Label1.Text = objReader("email")

strSQL is a select command which I've checked (using SQL Query analyzer) does return data. I know the connection string is valid (and I presume if it wasn't that it'd fail on objCon2.open, which it doesn't).

So why oh why do I get this error on the last line (and yes, there is an "email" field in the contents of the reader)

System.InvalidOperationException: Invalid attempt to read when no data is present.You have to move the "read head" to the start of a record by calling objReader.Read(). You do this each time you want to move to the next record. Since in your case there is presumably only one record you only need to call it once.


objReader = objCommand.ExecuteReader()
if objReader.Read()
Label1.Text = objReader("email")
End If
' be sure to close and the data reader afterwards
objReader.Close()

Sunday, February 26, 2012

Databases mirrong configuration question!

Hi all,
i could not find the answer to this on the net so i asked it here.
If i setup mirroring with standard config:
1 server with sql5000 server with 1 named instance (principal)
1 server with sql5000 server with 1 named instance (mirror)
1 server with sql5000 server with 1 named instance( witness)
Then i add a second named instance on the principal with some databases.
Must i setup an new config with witness and mirror to setp mirroring for
these databases?Or is it just simply selecting the databases in the new
instance and mirror them to the existing Mirror server and witness?
Many thx
--
I drank alot of beer and ended up in the police department database.
Drank more beer and learned SQL in the dark hours.
DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
I love SQL Oeps....correction in my hurry i typed sql5000.... that will take while.
..
Offcourse i mean SQL 2005 and a normal server ...not clustered.
--
"Hate_orphaned_users" wrote:

> Hi all,
> i could not find the answer to this on the net so i asked it here.
> If i setup mirroring with standard config:
> 1 server with sql5000 server with 1 named instance (principal)
> 1 server with sql5000 server with 1 named instance (mirror)
> 1 server with sql5000 server with 1 named instance( witness)
> Then i add a second named instance on the principal with some databases.
> Must i setup an new config with witness and mirror to setp mirroring for
> these databases?Or is it just simply selecting the databases in the new
> instance and mirror them to the existing Mirror server and witness?
> Many thx
> --
> I drank alot of beer and ended up in the police department database.
> Drank more beer and learned SQL in the dark hours.
> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> I love SQL
>|||You use the same endpoints on the mirror and the witness. On the new instanc
e, you need to add the
endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enab
le mirroring.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in
message
news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...[vbcol=seagreen]
> Oeps....correction in my hurry i typed sql5000.... that will take whil
e...
> Offcourse i mean SQL 2005 and a normal server ...not clustered.
> --
>
>
> "Hate_orphaned_users" wrote:
>|||thx !
--
"Tibor Karaszi" wrote:

> You use the same endpoints on the mirror and the witness. On the new insta
nce, you need to add the
> endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to en
able mirroring.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote
in message
> news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
>

Databases mirrong configuration question!

Hi all,
i could not find the answer to this on the net so i asked it here.
If i setup mirroring with standard config:
1 server with sql5000 server with 1 named instance (principal)
1 server with sql5000 server with 1 named instance (mirror)
1 server with sql5000 server with 1 named instance( witness)
Then i add a second named instance on the principal with some databases.
Must i setup an new config with witness and mirror to setp mirroring for
these databases?Or is it just simply selecting the databases in the new
instance and mirror them to the existing Mirror server and witness?
Many thx
I drank alot of beer and ended up in the police department database.
Drank more beer and learned SQL in the dark hours.
DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
I love SQL
Oeps....correction in my hurry i typed sql5000.... that will take while...
Offcourse i mean SQL 2005 and a normal server ...not clustered.
"Hate_orphaned_users" wrote:

> Hi all,
> i could not find the answer to this on the net so i asked it here.
> If i setup mirroring with standard config:
> 1 server with sql5000 server with 1 named instance (principal)
> 1 server with sql5000 server with 1 named instance (mirror)
> 1 server with sql5000 server with 1 named instance( witness)
> Then i add a second named instance on the principal with some databases.
> Must i setup an new config with witness and mirror to setp mirroring for
> these databases?Or is it just simply selecting the databases in the new
> instance and mirror them to the existing Mirror server and witness?
> Many thx
> --
> I drank alot of beer and ended up in the police department database.
> Drank more beer and learned SQL in the dark hours.
> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> I love SQL
>
|||You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...[vbcol=seagreen]
> Oeps....correction in my hurry i typed sql5000.... that will take while...
> Offcourse i mean SQL 2005 and a normal server ...not clustered.
> --
>
>
> "Hate_orphaned_users" wrote:
|||thx !
"Tibor Karaszi" wrote:

> You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
> endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
> news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
>

Databases mirrong configuration question!

Hi all,
i could not find the answer to this on the net so i asked it here.
If i setup mirroring with standard config:
1 server with sql5000 server with 1 named instance (principal)
1 server with sql5000 server with 1 named instance (mirror)
1 server with sql5000 server with 1 named instance( witness)
Then i add a second named instance on the principal with some databases.
Must i setup an new config with witness and mirror to setp mirroring for
these databases?Or is it just simply selecting the databases in the new
instance and mirror them to the existing Mirror server and witness?
Many thx
--
I drank alot of beer and ended up in the police department database.
Drank more beer and learned SQL in the dark hours.
DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
I love SQL :)Oeps....correction in my hurry i typed sql5000....:) that will take while...
Offcourse i mean SQL 2005 and a normal server ...not clustered.
--
"Hate_orphaned_users" wrote:
> Hi all,
> i could not find the answer to this on the net so i asked it here.
> If i setup mirroring with standard config:
> 1 server with sql5000 server with 1 named instance (principal)
> 1 server with sql5000 server with 1 named instance (mirror)
> 1 server with sql5000 server with 1 named instance( witness)
> Then i add a second named instance on the principal with some databases.
> Must i setup an new config with witness and mirror to setp mirroring for
> these databases?Or is it just simply selecting the databases in the new
> instance and mirror them to the existing Mirror server and witness?
> Many thx
> --
> I drank alot of beer and ended up in the police department database.
> Drank more beer and learned SQL in the dark hours.
> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> I love SQL :)
>|||You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
> Oeps....correction in my hurry i typed sql5000....:) that will take while...
> Offcourse i mean SQL 2005 and a normal server ...not clustered.
> --
>
>
> "Hate_orphaned_users" wrote:
>> Hi all,
>> i could not find the answer to this on the net so i asked it here.
>> If i setup mirroring with standard config:
>> 1 server with sql5000 server with 1 named instance (principal)
>> 1 server with sql5000 server with 1 named instance (mirror)
>> 1 server with sql5000 server with 1 named instance( witness)
>> Then i add a second named instance on the principal with some databases.
>> Must i setup an new config with witness and mirror to setp mirroring for
>> these databases?Or is it just simply selecting the databases in the new
>> instance and mirror them to the existing Mirror server and witness?
>> Many thx
>> --
>> I drank alot of beer and ended up in the police department database.
>> Drank more beer and learned SQL in the dark hours.
>> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
>> I love SQL :)
>>|||thx !
--
"Tibor Karaszi" wrote:
> You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
> endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
> news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
> > Oeps....correction in my hurry i typed sql5000....:) that will take while...
> > Offcourse i mean SQL 2005 and a normal server ...not clustered.
> > --
> >
> >
> >
> >
> >
> > "Hate_orphaned_users" wrote:
> >
> >> Hi all,
> >>
> >> i could not find the answer to this on the net so i asked it here.
> >> If i setup mirroring with standard config:
> >> 1 server with sql5000 server with 1 named instance (principal)
> >> 1 server with sql5000 server with 1 named instance (mirror)
> >> 1 server with sql5000 server with 1 named instance( witness)
> >> Then i add a second named instance on the principal with some databases.
> >> Must i setup an new config with witness and mirror to setp mirroring for
> >> these databases?Or is it just simply selecting the databases in the new
> >> instance and mirror them to the existing Mirror server and witness?
> >>
> >> Many thx
> >> --
> >> I drank alot of beer and ended up in the police department database.
> >> Drank more beer and learned SQL in the dark hours.
> >> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> >> I love SQL :)
> >>
> >>
>