Home All Groups Group Topic Archive Search About

ADO.NET Problem write or wrong

Author
26 Dec 2006 6:01 PM
Andrew
I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
if I am using it right or not?

Imports System.Data.sqlclient
Imports System.Data

Public Class Form1

    Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

        Dim conn As New SqlConnection("Server=apw-db;" & _
                        "DataBase=APW-System; Integrated Security=SSPI")
        Dim sqlstr As String = "SELECT * FROM sysName"
        Dim da As SqlDataAdapter
        Dim ds As New DataSet
        da = New SqlDataAdapter(sqlstr, conn)
        da.Fill(ds)
        Dim dt As DataTable = ds.Tables(0)

        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field

    End Sub
End Class

Author
26 Dec 2006 6:04 PM
Andrew
I am using sql 2005 and vb 2005

Show quoteHide quote
"Andrew" wrote:

> I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
> if I am using it right or not?
>
> Imports System.Data.sqlclient
> Imports System.Data
>
> Public Class Form1
>
>     Inherits System.Windows.Forms.Form
>
>  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
>         Dim conn As New SqlConnection("Server=apw-db;" & _
>                         "DataBase=APW-System; Integrated Security=SSPI")
>         Dim sqlstr As String = "SELECT * FROM sysName"
>         Dim da As SqlDataAdapter
>         Dim ds As New DataSet
>         da = New SqlDataAdapter(sqlstr, conn)
>         da.Fill(ds)
>         Dim dt As DataTable = ds.Tables(0)
>
>         MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
>
>     End Sub
> End Class
Author
26 Dec 2006 6:33 PM
Branco Medeiros
Andrew wrote:
> I am using sql 2005 and vb 2005
>
> "Andrew" wrote:
>
> > I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
> > if I am using it right or not?
<snip>

This worked for me: I first completely disregarded the several wizards
that come with VB 2005 and tried my hand in creating a strongly-typed
version of a database we have here. After struggling (and actually
succeeding) with this approach for a few days, I reckoned I had enough
control and knowledge of ADO.NET to give the designers a try. Currently
I'm using the designers for most new apps -- they're actually cool, if
you don't look under their dresses... =))

The experience with a hand-made strongly-typed db system tought me some
lessons and gave me a broarder perspective of the ADO.NET engine
workings. As they say, your mileage may vary. And it allowed me to
understand enough of it (I guess) to make it easier to extend the
functionality of the wizard generated items when necessary.

HTH.

Regards,

Branco.
Author
26 Dec 2006 6:09 PM
Cor Ligthert [MVP]
Andrew,

Nothing wrong with in my idea, however I would do it in its simplest format
in this way.

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
>        Dim conn As New SqlConnection("Server=apw-db;" & _
>                        "DataBase=APW-System; Integrated Security=SSPI")
>        Dim sqlstr As String = "SELECT * FROM sysName"
          Dim da As new SqlDataAdapter(sqlstr, conn)
>        Dim ds As New DataSet
          Try
>        da.Fill(ds)
          MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying to show
what is in field
          Catch ex as Exception
          MessageBox.Show(ex.ToString)
          End Try
>    End Sub

I hope this helps,

Cor


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> schreef in bericht
news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>I am simple tryint to learn how to use the ADO.NET code. Can anybody tell
>me
> if I am using it right or not?
>
> Imports System.Data.sqlclient
> Imports System.Data
>
> Public Class Form1
>
>    Inherits System.Windows.Forms.Form
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
>        Dim conn As New SqlConnection("Server=apw-db;" & _
>                        "DataBase=APW-System; Integrated Security=SSPI")
>        Dim sqlstr As String = "SELECT * FROM sysName"
>        Dim da As SqlDataAdapter
>        Dim ds As New DataSet
>        da = New SqlDataAdapter(sqlstr, conn)
>        da.Fill(ds)
>        Dim dt As DataTable = ds.Tables(0)
>
>        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
>
>    End Sub
> End Class
Author
26 Dec 2006 6:31 PM
Andrew
when I put as you put I get an error : "System.data.datarow" cannot be
converted to string.

when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))

I get a new message:

system.nullfreferenceExecptoin: Object Reference not set to instaance of an
Object.
as windowsApplication1.form1.button1_click() app path
ADodb.net\windowsaplication1\form1.vb:line71

I have one row with information in this table and the field is a
nvarchar(max) with allow nulls checked.

Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Andrew,
>
> Nothing wrong with in my idea, however I would do it in its simplest format
> in this way.
>
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> >
> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >        Dim sqlstr As String = "SELECT * FROM sysName"
>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >        Dim ds As New DataSet
>           Try
> >        da.Fill(ds)
>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying to show
> what is in field
>           Catch ex as Exception
>           MessageBox.Show(ex.ToString)
>           End Try
> >    End Sub
>
> I hope this helps,
>
> Cor
>
>
> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >I am simple tryint to learn how to use the ADO.NET code. Can anybody tell
> >me
> > if I am using it right or not?
> >
> > Imports System.Data.sqlclient
> > Imports System.Data
> >
> > Public Class Form1
> >
> >    Inherits System.Windows.Forms.Form
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> >
> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >        Dim da As SqlDataAdapter
> >        Dim ds As New DataSet
> >        da = New SqlDataAdapter(sqlstr, conn)
> >        da.Fill(ds)
> >        Dim dt As DataTable = ds.Tables(0)
> >
> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
> >
> >    End Sub
> > End Class
>
>
>
Author
26 Dec 2006 6:49 PM
Cor Ligthert [MVP]
Andrew,

Sorry, this can be
    Cstr(ds.Tables(0).Rows(0).Item("sysName"))
    ds.Tables(0).Rows(0).Item("sysName").ToString
    Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)

Most people including me use the ToString,

I have typed it in the message, looking at the major points.

I hope it will go now, again not tested just typed.

Cor


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> schreef in bericht
news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> when I put as you put I get an error : "System.data.datarow" cannot be
> converted to string.
>
> when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>
> I get a new message:
>
> system.nullfreferenceExecptoin: Object Reference not set to instaance of
> an
> Object.
> as windowsApplication1.form1.button1_click() app path
> ADodb.net\windowsaplication1\form1.vb:line71
>
> I have one row with information in this table and the field is a
> nvarchar(max) with allow nulls checked.
>
> "Cor Ligthert [MVP]" wrote:
>
>> Andrew,
>>
>> Nothing wrong with in my idea, however I would do it in its simplest
>> format
>> in this way.
>>
>> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles Button1.Click
>> >
>> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >                        "DataBase=APW-System; Integrated Security=SSPI")
>> >        Dim sqlstr As String = "SELECT * FROM sysName"
>>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >        Dim ds As New DataSet
>>           Try
>> >        da.Fill(ds)
>>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying to
>> show
>> what is in field
>>           Catch ex as Exception
>>           MessageBox.Show(ex.ToString)
>>           End Try
>> >    End Sub
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
>> >tell
>> >me
>> > if I am using it right or not?
>> >
>> > Imports System.Data.sqlclient
>> > Imports System.Data
>> >
>> > Public Class Form1
>> >
>> >    Inherits System.Windows.Forms.Form
>> >
>> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles Button1.Click
>> >
>> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >                        "DataBase=APW-System; Integrated Security=SSPI")
>> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >        Dim da As SqlDataAdapter
>> >        Dim ds As New DataSet
>> >        da = New SqlDataAdapter(sqlstr, conn)
>> >        da.Fill(ds)
>> >        Dim dt As DataTable = ds.Tables(0)
>> >
>> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
>> >
>> >    End Sub
>> > End Class
>>
>>
>>
Author
26 Dec 2006 7:38 PM
Andrew
I found one of the problems there was no (0) after Rows in my code, but now
when I execute I get the Exception error:

system.NullreferenceExection: Object reference not set to an instance of an
object.

Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Andrew,
>
> Sorry, this can be
>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>     ds.Tables(0).Rows(0).Item("sysName").ToString
>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>
> Most people including me use the ToString,
>
> I have typed it in the message, looking at the major points.
>
> I hope it will go now, again not tested just typed.
>
> Cor
>
>
> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> > when I put as you put I get an error : "System.data.datarow" cannot be
> > converted to string.
> >
> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >
> > I get a new message:
> >
> > system.nullfreferenceExecptoin: Object Reference not set to instaance of
> > an
> > Object.
> > as windowsApplication1.form1.button1_click() app path
> > ADodb.net\windowsaplication1\form1.vb:line71
> >
> > I have one row with information in this table and the field is a
> > nvarchar(max) with allow nulls checked.
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Andrew,
> >>
> >> Nothing wrong with in my idea, however I would do it in its simplest
> >> format
> >> in this way.
> >>
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >        Dim ds As New DataSet
> >>           Try
> >> >        da.Fill(ds)
> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying to
> >> show
> >> what is in field
> >>           Catch ex as Exception
> >>           MessageBox.Show(ex.ToString)
> >>           End Try
> >> >    End Sub
> >>
> >> I hope this helps,
> >>
> >> Cor
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
> >> >tell
> >> >me
> >> > if I am using it right or not?
> >> >
> >> > Imports System.Data.sqlclient
> >> > Imports System.Data
> >> >
> >> > Public Class Form1
> >> >
> >> >    Inherits System.Windows.Forms.Form
> >> >
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >        Dim da As SqlDataAdapter
> >> >        Dim ds As New DataSet
> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >        da.Fill(ds)
> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >
> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
> >> >
> >> >    End Sub
> >> > End Class
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 8:07 PM
Cor Ligthert [MVP]
Andrew,

>I found one of the problems there was no (0) after Rows in my code, but now
> when I execute I get the Exception error:
>
>>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>>     ds.Tables(0).Rows(0).Item("sysName").ToString
>>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>>

I thought that I showed you that above. In what row is the exception error?.

Cor

Show quoteHide quote
>> Most people including me use the ToString,
>>
>> I have typed it in the message, looking at the major points.
>>
>> I hope it will go now, again not tested just typed.
>>
>> Cor
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
>> > when I put as you put I get an error : "System.data.datarow" cannot be
>> > converted to string.
>> >
>> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>> >
>> > I get a new message:
>> >
>> > system.nullfreferenceExecptoin: Object Reference not set to instaance
>> > of
>> > an
>> > Object.
>> > as windowsApplication1.form1.button1_click() app path
>> > ADodb.net\windowsaplication1\form1.vb:line71
>> >
>> > I have one row with information in this table and the field is a
>> > nvarchar(max) with allow nulls checked.
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >> Andrew,
>> >>
>> >> Nothing wrong with in my idea, however I would do it in its simplest
>> >> format
>> >> in this way.
>> >>
>> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> >> > System.EventArgs) Handles Button1.Click
>> >> >
>> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >                        "DataBase=APW-System; Integrated
>> >> > Security=SSPI")
>> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >> >        Dim ds As New DataSet
>> >>           Try
>> >> >        da.Fill(ds)
>> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying
>> >> to
>> >> show
>> >> what is in field
>> >>           Catch ex as Exception
>> >>           MessageBox.Show(ex.ToString)
>> >>           End Try
>> >> >    End Sub
>> >>
>> >> I hope this helps,
>> >>
>> >> Cor
>> >>
>> >>
>> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
>> >> >tell
>> >> >me
>> >> > if I am using it right or not?
>> >> >
>> >> > Imports System.Data.sqlclient
>> >> > Imports System.Data
>> >> >
>> >> > Public Class Form1
>> >> >
>> >> >    Inherits System.Windows.Forms.Form
>> >> >
>> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> >> > System.EventArgs) Handles Button1.Click
>> >> >
>> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >                        "DataBase=APW-System; Integrated
>> >> > Security=SSPI")
>> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >        Dim da As SqlDataAdapter
>> >> >        Dim ds As New DataSet
>> >> >        da = New SqlDataAdapter(sqlstr, conn)
>> >> >        da.Fill(ds)
>> >> >        Dim dt As DataTable = ds.Tables(0)
>> >> >
>> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
>> >> > field
>> >> >
>> >> >    End Sub
>> >> > End Class
>> >>
>> >>
>> >>
>>
>>
>>
Author
26 Dec 2006 8:14 PM
Andrew
I had make a mistake and mistyped what you had. but the error is coming from
row 71 on my app, the same row were I have the da.fill(ds).



Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Andrew,
>
> >I found one of the problems there was no (0) after Rows in my code, but now
> > when I execute I get the Exception error:
> >
> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >>
>
> I thought that I showed you that above. In what row is the exception error?.
>
> Cor
>
> >> Most people including me use the ToString,
> >>
> >> I have typed it in the message, looking at the major points.
> >>
> >> I hope it will go now, again not tested just typed.
> >>
> >> Cor
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> > when I put as you put I get an error : "System.data.datarow" cannot be
> >> > converted to string.
> >> >
> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >
> >> > I get a new message:
> >> >
> >> > system.nullfreferenceExecptoin: Object Reference not set to instaance
> >> > of
> >> > an
> >> > Object.
> >> > as windowsApplication1.form1.button1_click() app path
> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >
> >> > I have one row with information in this table and the field is a
> >> > nvarchar(max) with allow nulls checked.
> >> >
> >> > "Cor Ligthert [MVP]" wrote:
> >> >
> >> >> Andrew,
> >> >>
> >> >> Nothing wrong with in my idea, however I would do it in its simplest
> >> >> format
> >> >> in this way.
> >> >>
> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >
> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >                        "DataBase=APW-System; Integrated
> >> >> > Security=SSPI")
> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >        Dim ds As New DataSet
> >> >>           Try
> >> >> >        da.Fill(ds)
> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying
> >> >> to
> >> >> show
> >> >> what is in field
> >> >>           Catch ex as Exception
> >> >>           MessageBox.Show(ex.ToString)
> >> >>           End Try
> >> >> >    End Sub
> >> >>
> >> >> I hope this helps,
> >> >>
> >> >> Cor
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
> >> >> >tell
> >> >> >me
> >> >> > if I am using it right or not?
> >> >> >
> >> >> > Imports System.Data.sqlclient
> >> >> > Imports System.Data
> >> >> >
> >> >> > Public Class Form1
> >> >> >
> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >
> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >
> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >                        "DataBase=APW-System; Integrated
> >> >> > Security=SSPI")
> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >        Dim da As SqlDataAdapter
> >> >> >        Dim ds As New DataSet
> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >        da.Fill(ds)
> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >
> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
> >> >> > field
> >> >> >
> >> >> >    End Sub
> >> >> > End Class
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 8:07 PM
Andrew
I think the error is coming from the:

     da.fill(ds)   ' function





Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Andrew,
>
> Sorry, this can be
>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>     ds.Tables(0).Rows(0).Item("sysName").ToString
>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>
> Most people including me use the ToString,
>
> I have typed it in the message, looking at the major points.
>
> I hope it will go now, again not tested just typed.
>
> Cor
>
>
> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> > when I put as you put I get an error : "System.data.datarow" cannot be
> > converted to string.
> >
> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >
> > I get a new message:
> >
> > system.nullfreferenceExecptoin: Object Reference not set to instaance of
> > an
> > Object.
> > as windowsApplication1.form1.button1_click() app path
> > ADodb.net\windowsaplication1\form1.vb:line71
> >
> > I have one row with information in this table and the field is a
> > nvarchar(max) with allow nulls checked.
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Andrew,
> >>
> >> Nothing wrong with in my idea, however I would do it in its simplest
> >> format
> >> in this way.
> >>
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >        Dim ds As New DataSet
> >>           Try
> >> >        da.Fill(ds)
> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying to
> >> show
> >> what is in field
> >>           Catch ex as Exception
> >>           MessageBox.Show(ex.ToString)
> >>           End Try
> >> >    End Sub
> >>
> >> I hope this helps,
> >>
> >> Cor
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
> >> >tell
> >> >me
> >> > if I am using it right or not?
> >> >
> >> > Imports System.Data.sqlclient
> >> > Imports System.Data
> >> >
> >> > Public Class Form1
> >> >
> >> >    Inherits System.Windows.Forms.Form
> >> >
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >        Dim da As SqlDataAdapter
> >> >        Dim ds As New DataSet
> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >        da.Fill(ds)
> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >
> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in field
> >> >
> >> >    End Sub
> >> > End Class
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 8:24 PM
Cor Ligthert [MVP]
Can you show your complete new code again,

Cor


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> schreef in bericht
news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
>I think the error is coming from the:
>
>     da.fill(ds)   ' function
>
>
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Andrew,
>>
>> Sorry, this can be
>>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>>     ds.Tables(0).Rows(0).Item("sysName").ToString
>>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>>
>> Most people including me use the ToString,
>>
>> I have typed it in the message, looking at the major points.
>>
>> I hope it will go now, again not tested just typed.
>>
>> Cor
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
>> > when I put as you put I get an error : "System.data.datarow" cannot be
>> > converted to string.
>> >
>> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>> >
>> > I get a new message:
>> >
>> > system.nullfreferenceExecptoin: Object Reference not set to instaance
>> > of
>> > an
>> > Object.
>> > as windowsApplication1.form1.button1_click() app path
>> > ADodb.net\windowsaplication1\form1.vb:line71
>> >
>> > I have one row with information in this table and the field is a
>> > nvarchar(max) with allow nulls checked.
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >> Andrew,
>> >>
>> >> Nothing wrong with in my idea, however I would do it in its simplest
>> >> format
>> >> in this way.
>> >>
>> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> >> > System.EventArgs) Handles Button1.Click
>> >> >
>> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >                        "DataBase=APW-System; Integrated
>> >> > Security=SSPI")
>> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >> >        Dim ds As New DataSet
>> >>           Try
>> >> >        da.Fill(ds)
>> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying
>> >> to
>> >> show
>> >> what is in field
>> >>           Catch ex as Exception
>> >>           MessageBox.Show(ex.ToString)
>> >>           End Try
>> >> >    End Sub
>> >>
>> >> I hope this helps,
>> >>
>> >> Cor
>> >>
>> >>
>> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
>> >> >tell
>> >> >me
>> >> > if I am using it right or not?
>> >> >
>> >> > Imports System.Data.sqlclient
>> >> > Imports System.Data
>> >> >
>> >> > Public Class Form1
>> >> >
>> >> >    Inherits System.Windows.Forms.Form
>> >> >
>> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> >> > System.EventArgs) Handles Button1.Click
>> >> >
>> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >                        "DataBase=APW-System; Integrated
>> >> > Security=SSPI")
>> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >        Dim da As SqlDataAdapter
>> >> >        Dim ds As New DataSet
>> >> >        da = New SqlDataAdapter(sqlstr, conn)
>> >> >        da.Fill(ds)
>> >> >        Dim dt As DataTable = ds.Tables(0)
>> >> >
>> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
>> >> > field
>> >> >
>> >> >    End Sub
>> >> > End Class
>> >>
>> >>
>> >>
>>
>>
>>
Author
26 Dec 2006 8:31 PM
Andrew
here is the new code:


Imports System.Data.sqlclient
Imports System.Data

Public Class Form1

    Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

        Dim conn As New SqlConnection("Server=apw-db;" & _
                        "DataBase=APW-System; Integrated Security=SSPI")
        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE sysName='IT_1'"
        Dim da As SqlDataAdapter
        Dim ds As New DataSet

        Try
            da.Fill(ds)

            MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
'trying to show what is in field
        Catch ex As Exception
            MessageBox.Show(ex.ToString)

        End Try

End Sub
End Class



Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

>
> Can you show your complete new code again,
>
> Cor
>
>
> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
> >I think the error is coming from the:
> >
> >     da.fill(ds)   ' function
> >
> >
> >
> >
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Andrew,
> >>
> >> Sorry, this can be
> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >>
> >> Most people including me use the ToString,
> >>
> >> I have typed it in the message, looking at the major points.
> >>
> >> I hope it will go now, again not tested just typed.
> >>
> >> Cor
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> > when I put as you put I get an error : "System.data.datarow" cannot be
> >> > converted to string.
> >> >
> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >
> >> > I get a new message:
> >> >
> >> > system.nullfreferenceExecptoin: Object Reference not set to instaance
> >> > of
> >> > an
> >> > Object.
> >> > as windowsApplication1.form1.button1_click() app path
> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >
> >> > I have one row with information in this table and the field is a
> >> > nvarchar(max) with allow nulls checked.
> >> >
> >> > "Cor Ligthert [MVP]" wrote:
> >> >
> >> >> Andrew,
> >> >>
> >> >> Nothing wrong with in my idea, however I would do it in its simplest
> >> >> format
> >> >> in this way.
> >> >>
> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >
> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >                        "DataBase=APW-System; Integrated
> >> >> > Security=SSPI")
> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >        Dim ds As New DataSet
> >> >>           Try
> >> >> >        da.Fill(ds)
> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) 'trying
> >> >> to
> >> >> show
> >> >> what is in field
> >> >>           Catch ex as Exception
> >> >>           MessageBox.Show(ex.ToString)
> >> >>           End Try
> >> >> >    End Sub
> >> >>
> >> >> I hope this helps,
> >> >>
> >> >> Cor
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can anybody
> >> >> >tell
> >> >> >me
> >> >> > if I am using it right or not?
> >> >> >
> >> >> > Imports System.Data.sqlclient
> >> >> > Imports System.Data
> >> >> >
> >> >> > Public Class Form1
> >> >> >
> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >
> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >
> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >                        "DataBase=APW-System; Integrated
> >> >> > Security=SSPI")
> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >        Dim da As SqlDataAdapter
> >> >> >        Dim ds As New DataSet
> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >        da.Fill(ds)
> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >
> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
> >> >> > field
> >> >> >
> >> >> >    End Sub
> >> >> > End Class
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 9:08 PM
Stephany Young
Instantiate da.


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
> here is the new code:
>
>
> Imports System.Data.sqlclient
> Imports System.Data
>
> Public Class Form1
>
>    Inherits System.Windows.Forms.Form
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
>        Dim conn As New SqlConnection("Server=apw-db;" & _
>                        "DataBase=APW-System; Integrated Security=SSPI")
>        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> sysName='IT_1'"
>        Dim da As SqlDataAdapter
>        Dim ds As New DataSet
>
>        Try
>            da.Fill(ds)
>
>            MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
> 'trying to show what is in field
>        Catch ex As Exception
>            MessageBox.Show(ex.ToString)
>
>        End Try
>
> End Sub
> End Class
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>>
>> Can you show your complete new code again,
>>
>> Cor
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
>> >I think the error is coming from the:
>> >
>> >     da.fill(ds)   ' function
>> >
>> >
>> >
>> >
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >> Andrew,
>> >>
>> >> Sorry, this can be
>> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
>> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>> >>
>> >> Most people including me use the ToString,
>> >>
>> >> I have typed it in the message, looking at the major points.
>> >>
>> >> I hope it will go now, again not tested just typed.
>> >>
>> >> Cor
>> >>
>> >>
>> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
>> >> > when I put as you put I get an error : "System.data.datarow" cannot
>> >> > be
>> >> > converted to string.
>> >> >
>> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>> >> >
>> >> > I get a new message:
>> >> >
>> >> > system.nullfreferenceExecptoin: Object Reference not set to
>> >> > instaance
>> >> > of
>> >> > an
>> >> > Object.
>> >> > as windowsApplication1.form1.button1_click() app path
>> >> > ADodb.net\windowsaplication1\form1.vb:line71
>> >> >
>> >> > I have one row with information in this table and the field is a
>> >> > nvarchar(max) with allow nulls checked.
>> >> >
>> >> > "Cor Ligthert [MVP]" wrote:
>> >> >
>> >> >> Andrew,
>> >> >>
>> >> >> Nothing wrong with in my idea, however I would do it in its
>> >> >> simplest
>> >> >> format
>> >> >> in this way.
>> >> >>
>> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
>> >> >> > As
>> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >
>> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> > Security=SSPI")
>> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >> >> >        Dim ds As New DataSet
>> >> >>           Try
>> >> >> >        da.Fill(ds)
>> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
>> >> >> 'trying
>> >> >> to
>> >> >> show
>> >> >> what is in field
>> >> >>           Catch ex as Exception
>> >> >>           MessageBox.Show(ex.ToString)
>> >> >>           End Try
>> >> >> >    End Sub
>> >> >>
>> >> >> I hope this helps,
>> >> >>
>> >> >> Cor
>> >> >>
>> >> >>
>> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
>> >> >> >anybody
>> >> >> >tell
>> >> >> >me
>> >> >> > if I am using it right or not?
>> >> >> >
>> >> >> > Imports System.Data.sqlclient
>> >> >> > Imports System.Data
>> >> >> >
>> >> >> > Public Class Form1
>> >> >> >
>> >> >> >    Inherits System.Windows.Forms.Form
>> >> >> >
>> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
>> >> >> > As
>> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >
>> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> > Security=SSPI")
>> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >> >        Dim da As SqlDataAdapter
>> >> >> >        Dim ds As New DataSet
>> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
>> >> >> >        da.Fill(ds)
>> >> >> >        Dim dt As DataTable = ds.Tables(0)
>> >> >> >
>> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
>> >> >> > field
>> >> >> >
>> >> >> >    End Sub
>> >> >> > End Class
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
Author
26 Dec 2006 9:22 PM
Andrew
how would I do that in .net?

Show quoteHide quote
"Stephany Young" wrote:

> Instantiate da.
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
> > here is the new code:
> >
> >
> > Imports System.Data.sqlclient
> > Imports System.Data
> >
> > Public Class Form1
> >
> >    Inherits System.Windows.Forms.Form
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> >
> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> > sysName='IT_1'"
> >        Dim da As SqlDataAdapter
> >        Dim ds As New DataSet
> >
> >        Try
> >            da.Fill(ds)
> >
> >            MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
> > 'trying to show what is in field
> >        Catch ex As Exception
> >            MessageBox.Show(ex.ToString)
> >
> >        End Try
> >
> > End Sub
> > End Class
> >
> >
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >>
> >> Can you show your complete new code again,
> >>
> >> Cor
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
> >> >I think the error is coming from the:
> >> >
> >> >     da.fill(ds)   ' function
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > "Cor Ligthert [MVP]" wrote:
> >> >
> >> >> Andrew,
> >> >>
> >> >> Sorry, this can be
> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >> >>
> >> >> Most people including me use the ToString,
> >> >>
> >> >> I have typed it in the message, looking at the major points.
> >> >>
> >> >> I hope it will go now, again not tested just typed.
> >> >>
> >> >> Cor
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> >> > when I put as you put I get an error : "System.data.datarow" cannot
> >> >> > be
> >> >> > converted to string.
> >> >> >
> >> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >> >
> >> >> > I get a new message:
> >> >> >
> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
> >> >> > instaance
> >> >> > of
> >> >> > an
> >> >> > Object.
> >> >> > as windowsApplication1.form1.button1_click() app path
> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >> >
> >> >> > I have one row with information in this table and the field is a
> >> >> > nvarchar(max) with allow nulls checked.
> >> >> >
> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >
> >> >> >> Andrew,
> >> >> >>
> >> >> >> Nothing wrong with in my idea, however I would do it in its
> >> >> >> simplest
> >> >> >> format
> >> >> >> in this way.
> >> >> >>
> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
> >> >> >> > As
> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >
> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> > Security=SSPI")
> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >> >        Dim ds As New DataSet
> >> >> >>           Try
> >> >> >> >        da.Fill(ds)
> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
> >> >> >> 'trying
> >> >> >> to
> >> >> >> show
> >> >> >> what is in field
> >> >> >>           Catch ex as Exception
> >> >> >>           MessageBox.Show(ex.ToString)
> >> >> >>           End Try
> >> >> >> >    End Sub
> >> >> >>
> >> >> >> I hope this helps,
> >> >> >>
> >> >> >> Cor
> >> >> >>
> >> >> >>
> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
> >> >> >> >anybody
> >> >> >> >tell
> >> >> >> >me
> >> >> >> > if I am using it right or not?
> >> >> >> >
> >> >> >> > Imports System.Data.sqlclient
> >> >> >> > Imports System.Data
> >> >> >> >
> >> >> >> > Public Class Form1
> >> >> >> >
> >> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >> >
> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
> >> >> >> > As
> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >
> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> > Security=SSPI")
> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >        Dim da As SqlDataAdapter
> >> >> >> >        Dim ds As New DataSet
> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >> >        da.Fill(ds)
> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >> >
> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is in
> >> >> >> > field
> >> >> >> >
> >> >> >> >    End Sub
> >> >> >> > End Class
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 9:31 PM
Stephany Young
You did it quite successfully in your original post.


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:2E575AF0-4172-4920-A0F9-2F744BB19CA4@microsoft.com...
> how would I do that in .net?
>
> "Stephany Young" wrote:
>
>> Instantiate da.
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> wrote in message
>> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
>> > here is the new code:
>> >
>> >
>> > Imports System.Data.sqlclient
>> > Imports System.Data
>> >
>> > Public Class Form1
>> >
>> >    Inherits System.Windows.Forms.Form
>> >
>> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles Button1.Click
>> >
>> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >                        "DataBase=APW-System; Integrated Security=SSPI")
>> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
>> > sysName='IT_1'"
>> >        Dim da As SqlDataAdapter
>> >        Dim ds As New DataSet
>> >
>> >        Try
>> >            da.Fill(ds)
>> >
>> >
>> > MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
>> > 'trying to show what is in field
>> >        Catch ex As Exception
>> >            MessageBox.Show(ex.ToString)
>> >
>> >        End Try
>> >
>> > End Sub
>> > End Class
>> >
>> >
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >>
>> >> Can you show your complete new code again,
>> >>
>> >> Cor
>> >>
>> >>
>> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
>> >> >I think the error is coming from the:
>> >> >
>> >> >     da.fill(ds)   ' function
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > "Cor Ligthert [MVP]" wrote:
>> >> >
>> >> >> Andrew,
>> >> >>
>> >> >> Sorry, this can be
>> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
>> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>> >> >>
>> >> >> Most people including me use the ToString,
>> >> >>
>> >> >> I have typed it in the message, looking at the major points.
>> >> >>
>> >> >> I hope it will go now, again not tested just typed.
>> >> >>
>> >> >> Cor
>> >> >>
>> >> >>
>> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
>> >> >> > when I put as you put I get an error : "System.data.datarow"
>> >> >> > cannot
>> >> >> > be
>> >> >> > converted to string.
>> >> >> >
>> >> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>> >> >> >
>> >> >> > I get a new message:
>> >> >> >
>> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
>> >> >> > instaance
>> >> >> > of
>> >> >> > an
>> >> >> > Object.
>> >> >> > as windowsApplication1.form1.button1_click() app path
>> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
>> >> >> >
>> >> >> > I have one row with information in this table and the field is a
>> >> >> > nvarchar(max) with allow nulls checked.
>> >> >> >
>> >> >> > "Cor Ligthert [MVP]" wrote:
>> >> >> >
>> >> >> >> Andrew,
>> >> >> >>
>> >> >> >> Nothing wrong with in my idea, however I would do it in its
>> >> >> >> simplest
>> >> >> >> format
>> >> >> >> in this way.
>> >> >> >>
>> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
>> >> >> >> > e
>> >> >> >> > As
>> >> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >> >
>> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> >> > Security=SSPI")
>> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >> >> >> >        Dim ds As New DataSet
>> >> >> >>           Try
>> >> >> >> >        da.Fill(ds)
>> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
>> >> >> >> 'trying
>> >> >> >> to
>> >> >> >> show
>> >> >> >> what is in field
>> >> >> >>           Catch ex as Exception
>> >> >> >>           MessageBox.Show(ex.ToString)
>> >> >> >>           End Try
>> >> >> >> >    End Sub
>> >> >> >>
>> >> >> >> I hope this helps,
>> >> >> >>
>> >> >> >> Cor
>> >> >> >>
>> >> >> >>
>> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
>> >> >> >> >anybody
>> >> >> >> >tell
>> >> >> >> >me
>> >> >> >> > if I am using it right or not?
>> >> >> >> >
>> >> >> >> > Imports System.Data.sqlclient
>> >> >> >> > Imports System.Data
>> >> >> >> >
>> >> >> >> > Public Class Form1
>> >> >> >> >
>> >> >> >> >    Inherits System.Windows.Forms.Form
>> >> >> >> >
>> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
>> >> >> >> > e
>> >> >> >> > As
>> >> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >> >
>> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> >> > Security=SSPI")
>> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >> >> >        Dim da As SqlDataAdapter
>> >> >> >> >        Dim ds As New DataSet
>> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
>> >> >> >> >        da.Fill(ds)
>> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
>> >> >> >> >
>> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is
>> >> >> >> > in
>> >> >> >> > field
>> >> >> >> >
>> >> >> >> >    End Sub
>> >> >> >> > End Class
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
Author
26 Dec 2006 9:46 PM
Andrew
Thanks for pointing that out, I was having a brain fart. At the time I got
this reply back I was noticing that there was no command execution for the
sql string. Not I am getting a reply back from the server, how ever I am not
use to logging in with windows authentication.

Is the provider string done the same way as in the previous version of
adodb. This is my string with the previous version

"Provider=SQLOLEDB.1;User ID=sa;password=" & sPassword & ";Initial Catalog="
& sDBName & ";Data Source = " & sServer & ";Use Procedure for Prepare=1;Auto
Translate=True;Packet Size=4096"

Is it the same in adodb.net or different?

and if I was to update a database through a sql string with this code, Do I
do the same type of execution with the update sql string?

example of old:


cmd.ActiveConnection = conn
                cmd.CommandText = "INSERT INTO driveMaster
(driveID,sysID,evenID,driveDate,driveLET,driveTtl,driveFree)" & _
                "VALUES (NEWID(), " & uID & ", 'ID3333', current_timestamp,
'" & sD & "', '" & iTtl & "', '" & iFree & "')"
                cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
                rs = cmd.Execute







Show quoteHide quote
"Stephany Young" wrote:

> You did it quite successfully in your original post.
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:2E575AF0-4172-4920-A0F9-2F744BB19CA4@microsoft.com...
> > how would I do that in .net?
> >
> > "Stephany Young" wrote:
> >
> >> Instantiate da.
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> wrote in message
> >> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
> >> > here is the new code:
> >> >
> >> >
> >> > Imports System.Data.sqlclient
> >> > Imports System.Data
> >> >
> >> > Public Class Form1
> >> >
> >> >    Inherits System.Windows.Forms.Form
> >> >
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> >> > sysName='IT_1'"
> >> >        Dim da As SqlDataAdapter
> >> >        Dim ds As New DataSet
> >> >
> >> >        Try
> >> >            da.Fill(ds)
> >> >
> >> >
> >> > MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
> >> > 'trying to show what is in field
> >> >        Catch ex As Exception
> >> >            MessageBox.Show(ex.ToString)
> >> >
> >> >        End Try
> >> >
> >> > End Sub
> >> > End Class
> >> >
> >> >
> >> >
> >> > "Cor Ligthert [MVP]" wrote:
> >> >
> >> >>
> >> >> Can you show your complete new code again,
> >> >>
> >> >> Cor
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
> >> >> >I think the error is coming from the:
> >> >> >
> >> >> >     da.fill(ds)   ' function
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >
> >> >> >> Andrew,
> >> >> >>
> >> >> >> Sorry, this can be
> >> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >> >> >>
> >> >> >> Most people including me use the ToString,
> >> >> >>
> >> >> >> I have typed it in the message, looking at the major points.
> >> >> >>
> >> >> >> I hope it will go now, again not tested just typed.
> >> >> >>
> >> >> >> Cor
> >> >> >>
> >> >> >>
> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> >> >> > when I put as you put I get an error : "System.data.datarow"
> >> >> >> > cannot
> >> >> >> > be
> >> >> >> > converted to string.
> >> >> >> >
> >> >> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >> >> >
> >> >> >> > I get a new message:
> >> >> >> >
> >> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
> >> >> >> > instaance
> >> >> >> > of
> >> >> >> > an
> >> >> >> > Object.
> >> >> >> > as windowsApplication1.form1.button1_click() app path
> >> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >> >> >
> >> >> >> > I have one row with information in this table and the field is a
> >> >> >> > nvarchar(max) with allow nulls checked.
> >> >> >> >
> >> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >> >
> >> >> >> >> Andrew,
> >> >> >> >>
> >> >> >> >> Nothing wrong with in my idea, however I would do it in its
> >> >> >> >> simplest
> >> >> >> >> format
> >> >> >> >> in this way.
> >> >> >> >>
> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
> >> >> >> >> > e
> >> >> >> >> > As
> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >
> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> > Security=SSPI")
> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >>           Try
> >> >> >> >> >        da.Fill(ds)
> >> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
> >> >> >> >> 'trying
> >> >> >> >> to
> >> >> >> >> show
> >> >> >> >> what is in field
> >> >> >> >>           Catch ex as Exception
> >> >> >> >>           MessageBox.Show(ex.ToString)
> >> >> >> >>           End Try
> >> >> >> >> >    End Sub
> >> >> >> >>
> >> >> >> >> I hope this helps,
> >> >> >> >>
> >> >> >> >> Cor
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
> >> >> >> >> >anybody
> >> >> >> >> >tell
> >> >> >> >> >me
> >> >> >> >> > if I am using it right or not?
> >> >> >> >> >
> >> >> >> >> > Imports System.Data.sqlclient
> >> >> >> >> > Imports System.Data
> >> >> >> >> >
> >> >> >> >> > Public Class Form1
> >> >> >> >> >
> >> >> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >> >> >
> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
> >> >> >> >> > e
> >> >> >> >> > As
> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >
> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> > Security=SSPI")
> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >> >        Dim da As SqlDataAdapter
> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >        da.Fill(ds)
> >> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >> >> >
> >> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is
> >> >> >> >> > in
> >> >> >> >> > field
> >> >> >> >> >
> >> >> >> >> >    End Sub
> >> >> >> >> > End Class
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 10:26 PM
Stephany Young
When you are using the SqlClient objects, DO NOT include the Provider clause
in the connection string.

If you are using SQl Server authentication then the minimum connection
string is:

  Data Source=<server>;Initial Catalog=<database>;User
ID=<username>;Password=<password>

where the tokens (<server>, <database>, <username> and <password>) are
replaced with your own values.

The 'new' method for doing an insert is to instantiate a SqlCommand object
and call it's ExecuteNONQuery method:

  Dim _con As New SqlConnection(_connectionstring)

  Dim _com As New SqlCommand(_insertsqlstring, _con)

  _com.Parameters.Add(_parametername, _parametertype).Value =
_parametervalue
  ' Add all required parameters

  _con.Open()

  _com.ExceuteNonQuery()

  _con.Close()

I suggest you study the documentation relating to the
System.Data.SqlClient.SqlCommand class along with the documentation for
other related classes.


Show quoteHide quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:AA56360C-730B-4E68-B907-5483C691D5CC@microsoft.com...
> Thanks for pointing that out, I was having a brain fart. At the time I got
> this reply back I was noticing that there was no command execution for the
> sql string. Not I am getting a reply back from the server, how ever I am
> not
> use to logging in with windows authentication.
>
> Is the provider string done the same way as in the previous version of
> adodb. This is my string with the previous version
>
> "Provider=SQLOLEDB.1;User ID=sa;password=" & sPassword & ";Initial
> Catalog="
> & sDBName & ";Data Source = " & sServer & ";Use Procedure for
> Prepare=1;Auto
> Translate=True;Packet Size=4096"
>
> Is it the same in adodb.net or different?
>
> and if I was to update a database through a sql string with this code, Do
> I
> do the same type of execution with the update sql string?
>
> example of old:
>
>
> cmd.ActiveConnection = conn
>                cmd.CommandText = "INSERT INTO driveMaster
> (driveID,sysID,evenID,driveDate,driveLET,driveTtl,driveFree)" & _
>                "VALUES (NEWID(), " & uID & ", 'ID3333', current_timestamp,
> '" & sD & "', '" & iTtl & "', '" & iFree & "')"
>                cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
>                rs = cmd.Execute
>
>
>
>
>
>
>
> "Stephany Young" wrote:
>
>> You did it quite successfully in your original post.
>>
>>
>> "Andrew" <And***@discussions.microsoft.com> wrote in message
>> news:2E575AF0-4172-4920-A0F9-2F744BB19CA4@microsoft.com...
>> > how would I do that in .net?
>> >
>> > "Stephany Young" wrote:
>> >
>> >> Instantiate da.
>> >>
>> >>
>> >> "Andrew" <And***@discussions.microsoft.com> wrote in message
>> >> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
>> >> > here is the new code:
>> >> >
>> >> >
>> >> > Imports System.Data.sqlclient
>> >> > Imports System.Data
>> >> >
>> >> > Public Class Form1
>> >> >
>> >> >    Inherits System.Windows.Forms.Form
>> >> >
>> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> >> > System.EventArgs) Handles Button1.Click
>> >> >
>> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >                        "DataBase=APW-System; Integrated
>> >> > Security=SSPI")
>> >> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
>> >> > sysName='IT_1'"
>> >> >        Dim da As SqlDataAdapter
>> >> >        Dim ds As New DataSet
>> >> >
>> >> >        Try
>> >> >            da.Fill(ds)
>> >> >
>> >> >
>> >> > MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
>> >> > 'trying to show what is in field
>> >> >        Catch ex As Exception
>> >> >            MessageBox.Show(ex.ToString)
>> >> >
>> >> >        End Try
>> >> >
>> >> > End Sub
>> >> > End Class
>> >> >
>> >> >
>> >> >
>> >> > "Cor Ligthert [MVP]" wrote:
>> >> >
>> >> >>
>> >> >> Can you show your complete new code again,
>> >> >>
>> >> >> Cor
>> >> >>
>> >> >>
>> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
>> >> >> >I think the error is coming from the:
>> >> >> >
>> >> >> >     da.fill(ds)   ' function
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > "Cor Ligthert [MVP]" wrote:
>> >> >> >
>> >> >> >> Andrew,
>> >> >> >>
>> >> >> >> Sorry, this can be
>> >> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
>> >> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
>> >> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
>> >> >> >>
>> >> >> >> Most people including me use the ToString,
>> >> >> >>
>> >> >> >> I have typed it in the message, looking at the major points.
>> >> >> >>
>> >> >> >> I hope it will go now, again not tested just typed.
>> >> >> >>
>> >> >> >> Cor
>> >> >> >>
>> >> >> >>
>> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
>> >> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
>> >> >> >> > when I put as you put I get an error : "System.data.datarow"
>> >> >> >> > cannot
>> >> >> >> > be
>> >> >> >> > converted to string.
>> >> >> >> >
>> >> >> >> > when I put
>> >> >> >> > convert.tostring(ds.Tables(0).Rows.Item("sysName")))
>> >> >> >> >
>> >> >> >> > I get a new message:
>> >> >> >> >
>> >> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
>> >> >> >> > instaance
>> >> >> >> > of
>> >> >> >> > an
>> >> >> >> > Object.
>> >> >> >> > as windowsApplication1.form1.button1_click() app path
>> >> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
>> >> >> >> >
>> >> >> >> > I have one row with information in this table and the field is
>> >> >> >> > a
>> >> >> >> > nvarchar(max) with allow nulls checked.
>> >> >> >> >
>> >> >> >> > "Cor Ligthert [MVP]" wrote:
>> >> >> >> >
>> >> >> >> >> Andrew,
>> >> >> >> >>
>> >> >> >> >> Nothing wrong with in my idea, however I would do it in its
>> >> >> >> >> simplest
>> >> >> >> >> format
>> >> >> >> >> in this way.
>> >> >> >> >>
>> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object,
>> >> >> >> >> > ByVal
>> >> >> >> >> > e
>> >> >> >> >> > As
>> >> >> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >> >> >
>> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> >> >> > Security=SSPI")
>> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
>> >> >> >> >> >        Dim ds As New DataSet
>> >> >> >> >>           Try
>> >> >> >> >> >        da.Fill(ds)
>> >> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
>> >> >> >> >> 'trying
>> >> >> >> >> to
>> >> >> >> >> show
>> >> >> >> >> what is in field
>> >> >> >> >>           Catch ex as Exception
>> >> >> >> >>           MessageBox.Show(ex.ToString)
>> >> >> >> >>           End Try
>> >> >> >> >> >    End Sub
>> >> >> >> >>
>> >> >> >> >> I hope this helps,
>> >> >> >> >>
>> >> >> >> >> Cor
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in
>> >> >> >> >> bericht
>> >> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
>> >> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
>> >> >> >> >> >anybody
>> >> >> >> >> >tell
>> >> >> >> >> >me
>> >> >> >> >> > if I am using it right or not?
>> >> >> >> >> >
>> >> >> >> >> > Imports System.Data.sqlclient
>> >> >> >> >> > Imports System.Data
>> >> >> >> >> >
>> >> >> >> >> > Public Class Form1
>> >> >> >> >> >
>> >> >> >> >> >    Inherits System.Windows.Forms.Form
>> >> >> >> >> >
>> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object,
>> >> >> >> >> > ByVal
>> >> >> >> >> > e
>> >> >> >> >> > As
>> >> >> >> >> > System.EventArgs) Handles Button1.Click
>> >> >> >> >> >
>> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
>> >> >> >> >> >                        "DataBase=APW-System; Integrated
>> >> >> >> >> > Security=SSPI")
>> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
>> >> >> >> >> >        Dim da As SqlDataAdapter
>> >> >> >> >> >        Dim ds As New DataSet
>> >> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
>> >> >> >> >> >        da.Fill(ds)
>> >> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
>> >> >> >> >> >
>> >> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what
>> >> >> >> >> > is
>> >> >> >> >> > in
>> >> >> >> >> > field
>> >> >> >> >> >
>> >> >> >> >> >    End Sub
>> >> >> >> >> > End Class
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
Author
26 Dec 2006 10:43 PM
Andrew
thanks for you help, I will defiantly work on that.

Show quoteHide quote
"Stephany Young" wrote:

> When you are using the SqlClient objects, DO NOT include the Provider clause
> in the connection string.
>
> If you are using SQl Server authentication then the minimum connection
> string is:
>
>   Data Source=<server>;Initial Catalog=<database>;User
> ID=<username>;Password=<password>
>
> where the tokens (<server>, <database>, <username> and <password>) are
> replaced with your own values.
>
> The 'new' method for doing an insert is to instantiate a SqlCommand object
> and call it's ExecuteNONQuery method:
>
>   Dim _con As New SqlConnection(_connectionstring)
>
>   Dim _com As New SqlCommand(_insertsqlstring, _con)
>
>   _com.Parameters.Add(_parametername, _parametertype).Value =
> _parametervalue
>   ' Add all required parameters
>
>   _con.Open()
>
>   _com.ExceuteNonQuery()
>
>   _con.Close()
>
> I suggest you study the documentation relating to the
> System.Data.SqlClient.SqlCommand class along with the documentation for
> other related classes.
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:AA56360C-730B-4E68-B907-5483C691D5CC@microsoft.com...
> > Thanks for pointing that out, I was having a brain fart. At the time I got
> > this reply back I was noticing that there was no command execution for the
> > sql string. Not I am getting a reply back from the server, how ever I am
> > not
> > use to logging in with windows authentication.
> >
> > Is the provider string done the same way as in the previous version of
> > adodb. This is my string with the previous version
> >
> > "Provider=SQLOLEDB.1;User ID=sa;password=" & sPassword & ";Initial
> > Catalog="
> > & sDBName & ";Data Source = " & sServer & ";Use Procedure for
> > Prepare=1;Auto
> > Translate=True;Packet Size=4096"
> >
> > Is it the same in adodb.net or different?
> >
> > and if I was to update a database through a sql string with this code, Do
> > I
> > do the same type of execution with the update sql string?
> >
> > example of old:
> >
> >
> > cmd.ActiveConnection = conn
> >                cmd.CommandText = "INSERT INTO driveMaster
> > (driveID,sysID,evenID,driveDate,driveLET,driveTtl,driveFree)" & _
> >                "VALUES (NEWID(), " & uID & ", 'ID3333', current_timestamp,
> > '" & sD & "', '" & iTtl & "', '" & iFree & "')"
> >                cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
> >                rs = cmd.Execute
> >
> >
> >
> >
> >
> >
> >
> > "Stephany Young" wrote:
> >
> >> You did it quite successfully in your original post.
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> wrote in message
> >> news:2E575AF0-4172-4920-A0F9-2F744BB19CA4@microsoft.com...
> >> > how would I do that in .net?
> >> >
> >> > "Stephany Young" wrote:
> >> >
> >> >> Instantiate da.
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> wrote in message
> >> >> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
> >> >> > here is the new code:
> >> >> >
> >> >> >
> >> >> > Imports System.Data.sqlclient
> >> >> > Imports System.Data
> >> >> >
> >> >> > Public Class Form1
> >> >> >
> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >
> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >
> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >                        "DataBase=APW-System; Integrated
> >> >> > Security=SSPI")
> >> >> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> >> >> > sysName='IT_1'"
> >> >> >        Dim da As SqlDataAdapter
> >> >> >        Dim ds As New DataSet
> >> >> >
> >> >> >        Try
> >> >> >            da.Fill(ds)
> >> >> >
> >> >> >
> >> >> > MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
> >> >> > 'trying to show what is in field
> >> >> >        Catch ex As Exception
> >> >> >            MessageBox.Show(ex.ToString)
> >> >> >
> >> >> >        End Try
> >> >> >
> >> >> > End Sub
> >> >> > End Class
> >> >> >
> >> >> >
> >> >> >
> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >
> >> >> >>
> >> >> >> Can you show your complete new code again,
> >> >> >>
> >> >> >> Cor
> >> >> >>
> >> >> >>
> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
> >> >> >> >I think the error is coming from the:
> >> >> >> >
> >> >> >> >     da.fill(ds)   ' function
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >> >
> >> >> >> >> Andrew,
> >> >> >> >>
> >> >> >> >> Sorry, this can be
> >> >> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >> >> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >> >> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >> >> >> >>
> >> >> >> >> Most people including me use the ToString,
> >> >> >> >>
> >> >> >> >> I have typed it in the message, looking at the major points.
> >> >> >> >>
> >> >> >> >> I hope it will go now, again not tested just typed.
> >> >> >> >>
> >> >> >> >> Cor
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> >> >> >> > when I put as you put I get an error : "System.data.datarow"
> >> >> >> >> > cannot
> >> >> >> >> > be
> >> >> >> >> > converted to string.
> >> >> >> >> >
> >> >> >> >> > when I put
> >> >> >> >> > convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >> >> >> >
> >> >> >> >> > I get a new message:
> >> >> >> >> >
> >> >> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
> >> >> >> >> > instaance
> >> >> >> >> > of
> >> >> >> >> > an
> >> >> >> >> > Object.
> >> >> >> >> > as windowsApplication1.form1.button1_click() app path
> >> >> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >> >> >> >
> >> >> >> >> > I have one row with information in this table and the field is
> >> >> >> >> > a
> >> >> >> >> > nvarchar(max) with allow nulls checked.
> >> >> >> >> >
> >> >> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >> >> >
> >> >> >> >> >> Andrew,
> >> >> >> >> >>
> >> >> >> >> >> Nothing wrong with in my idea, however I would do it in its
> >> >> >> >> >> simplest
> >> >> >> >> >> format
> >> >> >> >> >> in this way.
> >> >> >> >> >>
> >> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object,
> >> >> >> >> >> > ByVal
> >> >> >> >> >> > e
> >> >> >> >> >> > As
> >> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >> >
> >> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> >> > Security=SSPI")
> >> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >> >>           Try
> >> >> >> >> >> >        da.Fill(ds)
> >> >> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
> >> >> >> >> >> 'trying
> >> >> >> >> >> to
> >> >> >> >> >> show
> >> >> >> >> >> what is in field
> >> >> >> >> >>           Catch ex as Exception
> >> >> >> >> >>           MessageBox.Show(ex.ToString)
> >> >> >> >> >>           End Try
> >> >> >> >> >> >    End Sub
> >> >> >> >> >>
> >> >> >> >> >> I hope this helps,
> >> >> >> >> >>
> >> >> >> >> >> Cor
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in
> >> >> >> >> >> bericht
> >> >> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
> >> >> >> >> >> >anybody
> >> >> >> >> >> >tell
> >> >> >> >> >> >me
> >> >> >> >> >> > if I am using it right or not?
> >> >> >> >> >> >
> >> >> >> >> >> > Imports System.Data.sqlclient
> >> >> >> >> >> > Imports System.Data
> >> >> >> >> >> >
> >> >> >> >> >> > Public Class Form1
> >> >> >> >> >> >
> >> >> >> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >> >> >> >
> >> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object,
> >> >> >> >> >> > ByVal
> >> >> >> >> >> > e
> >> >> >> >> >> > As
> >> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >> >
> >> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> >> > Security=SSPI")
> >> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >> >> >        Dim da As SqlDataAdapter
> >> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >> >        da.Fill(ds)
> >> >> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >> >> >> >
> >> >> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what
> >> >> >> >> >> > is
> >> >> >> >> >> > in
> >> >> >> >> >> > field
> >> >> >> >> >> >
> >> >> >> >> >> >    End Sub
> >> >> >> >> >> > End Class
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
26 Dec 2006 9:51 PM
Andrew
thanks for pointing that out, I was having a brian fart. At the time I got
this reply back I was noticing that there was no command execution for the
sql string. Not I am getting a reply back from the server, how ever I am not
use to loging in with windows authinication.

Show quoteHide quote
"Stephany Young" wrote:

> You did it quite successfully in your original post.
>
>
> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:2E575AF0-4172-4920-A0F9-2F744BB19CA4@microsoft.com...
> > how would I do that in .net?
> >
> > "Stephany Young" wrote:
> >
> >> Instantiate da.
> >>
> >>
> >> "Andrew" <And***@discussions.microsoft.com> wrote in message
> >> news:0AD0BAC4-522C-44D3-BCDE-63F08220BE02@microsoft.com...
> >> > here is the new code:
> >> >
> >> >
> >> > Imports System.Data.sqlclient
> >> > Imports System.Data
> >> >
> >> > Public Class Form1
> >> >
> >> >    Inherits System.Windows.Forms.Form
> >> >
> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> >> > System.EventArgs) Handles Button1.Click
> >> >
> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >                        "DataBase=APW-System; Integrated Security=SSPI")
> >> >        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> >> > sysName='IT_1'"
> >> >        Dim da As SqlDataAdapter
> >> >        Dim ds As New DataSet
> >> >
> >> >        Try
> >> >            da.Fill(ds)
> >> >
> >> >
> >> > MessageBox.Show(ds.Tables(0).Rows(0).Item("sysName").ToString)
> >> > 'trying to show what is in field
> >> >        Catch ex As Exception
> >> >            MessageBox.Show(ex.ToString)
> >> >
> >> >        End Try
> >> >
> >> > End Sub
> >> > End Class
> >> >
> >> >
> >> >
> >> > "Cor Ligthert [MVP]" wrote:
> >> >
> >> >>
> >> >> Can you show your complete new code again,
> >> >>
> >> >> Cor
> >> >>
> >> >>
> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> news:B317D639-6D4B-4562-A4F5-4DB895EC9AED@microsoft.com...
> >> >> >I think the error is coming from the:
> >> >> >
> >> >> >     da.fill(ds)   ' function
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >
> >> >> >> Andrew,
> >> >> >>
> >> >> >> Sorry, this can be
> >> >> >>     Cstr(ds.Tables(0).Rows(0).Item("sysName"))
> >> >> >>     ds.Tables(0).Rows(0).Item("sysName").ToString
> >> >> >>     Ctype(ds.Tables(0).Rows(0).Item("sysName"),String)
> >> >> >>
> >> >> >> Most people including me use the ToString,
> >> >> >>
> >> >> >> I have typed it in the message, looking at the major points.
> >> >> >>
> >> >> >> I hope it will go now, again not tested just typed.
> >> >> >>
> >> >> >> Cor
> >> >> >>
> >> >> >>
> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> news:077901A1-9479-4278-8E3C-37DEC01C7990@microsoft.com...
> >> >> >> > when I put as you put I get an error : "System.data.datarow"
> >> >> >> > cannot
> >> >> >> > be
> >> >> >> > converted to string.
> >> >> >> >
> >> >> >> > when I put convert.tostring(ds.Tables(0).Rows.Item("sysName")))
> >> >> >> >
> >> >> >> > I get a new message:
> >> >> >> >
> >> >> >> > system.nullfreferenceExecptoin: Object Reference not set to
> >> >> >> > instaance
> >> >> >> > of
> >> >> >> > an
> >> >> >> > Object.
> >> >> >> > as windowsApplication1.form1.button1_click() app path
> >> >> >> > ADodb.net\windowsaplication1\form1.vb:line71
> >> >> >> >
> >> >> >> > I have one row with information in this table and the field is a
> >> >> >> > nvarchar(max) with allow nulls checked.
> >> >> >> >
> >> >> >> > "Cor Ligthert [MVP]" wrote:
> >> >> >> >
> >> >> >> >> Andrew,
> >> >> >> >>
> >> >> >> >> Nothing wrong with in my idea, however I would do it in its
> >> >> >> >> simplest
> >> >> >> >> format
> >> >> >> >> in this way.
> >> >> >> >>
> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
> >> >> >> >> > e
> >> >> >> >> > As
> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >
> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> > Security=SSPI")
> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >>           Try
> >> >> >> >> >        da.Fill(ds)
> >> >> >> >>           MessageBox.Show(ds.Tables(0).Rows.Item("sysName"))
> >> >> >> >> 'trying
> >> >> >> >> to
> >> >> >> >> show
> >> >> >> >> what is in field
> >> >> >> >>           Catch ex as Exception
> >> >> >> >>           MessageBox.Show(ex.ToString)
> >> >> >> >>           End Try
> >> >> >> >> >    End Sub
> >> >> >> >>
> >> >> >> >> I hope this helps,
> >> >> >> >>
> >> >> >> >> Cor
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Andrew" <And***@discussions.microsoft.com> schreef in bericht
> >> >> >> >> news:0355ADCB-BE94-4D60-882A-E5D9ABDACDCD@microsoft.com...
> >> >> >> >> >I am simple tryint to learn how to use the ADO.NET code. Can
> >> >> >> >> >anybody
> >> >> >> >> >tell
> >> >> >> >> >me
> >> >> >> >> > if I am using it right or not?
> >> >> >> >> >
> >> >> >> >> > Imports System.Data.sqlclient
> >> >> >> >> > Imports System.Data
> >> >> >> >> >
> >> >> >> >> > Public Class Form1
> >> >> >> >> >
> >> >> >> >> >    Inherits System.Windows.Forms.Form
> >> >> >> >> >
> >> >> >> >> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal
> >> >> >> >> > e
> >> >> >> >> > As
> >> >> >> >> > System.EventArgs) Handles Button1.Click
> >> >> >> >> >
> >> >> >> >> >        Dim conn As New SqlConnection("Server=apw-db;" & _
> >> >> >> >> >                        "DataBase=APW-System; Integrated
> >> >> >> >> > Security=SSPI")
> >> >> >> >> >        Dim sqlstr As String = "SELECT * FROM sysName"
> >> >> >> >> >        Dim da As SqlDataAdapter
> >> >> >> >> >        Dim ds As New DataSet
> >> >> >> >> >        da = New SqlDataAdapter(sqlstr, conn)
> >> >> >> >> >        da.Fill(ds)
> >> >> >> >> >        Dim dt As DataTable = ds.Tables(0)
> >> >> >> >> >
> >> >> >> >> >        MsgBox(dt.Rows.Item("sysName")) 'trying to show what is
> >> >> >> >> > in
> >> >> >> >> > field
> >> >> >> >> >
> >> >> >> >> >    End Sub
> >> >> >> >> > End Class
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
27 Dec 2006 1:40 AM
Cor Ligthert [MVP]
Show quote Hide quote
>
> Imports System.Data.sqlclient
> Imports System.Data
>
> Public Class Form1
>
>    Inherits System.Windows.Forms.Form
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
>        Dim conn As New SqlConnection("Server=apw-db;" & _
>                        "DataBase=APW-System; Integrated Security=SSPI")
>        Dim sqlstr As String = "SELECT * FROM sysMaster WHERE
> sysName='IT_1'"
>        Dim da As SqlDataAdapter
>> >> >>           Dim da As new SqlDataAdapter(sqlstr, conn)