Click here to Skip to main content
15,914,780 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: how to add all fonts in a combo Pin
Dave Kreskowiak31-Jul-07 6:59
mveDave Kreskowiak31-Jul-07 6:59 
GeneralRe: how to add all fonts in a combo Pin
The Man from U.N.C.L.E.31-Jul-07 8:05
The Man from U.N.C.L.E.31-Jul-07 8:05 
GeneralRe: how to add all fonts in a combo Pin
eyes200731-Jul-07 19:51
eyes200731-Jul-07 19:51 
QuestionEmailing data Pin
IETaxguard31-Jul-07 4:02
IETaxguard31-Jul-07 4:02 
AnswerRe: Emailing data Pin
Dave Kreskowiak31-Jul-07 7:18
mveDave Kreskowiak31-Jul-07 7:18 
Questioninserting records using vb.net Pin
jds120731-Jul-07 3:41
jds120731-Jul-07 3:41 
AnswerRe: inserting records using vb.net Pin
Tim Carmichael31-Jul-07 3:50
Tim Carmichael31-Jul-07 3:50 
QuestionThe Scope of the Adapter in the Following code Pin
Vimalsoft(Pty) Ltd31-Jul-07 3:16
professionalVimalsoft(Pty) Ltd31-Jul-07 3:16 
Am using vb.net 2003, i was used to the drag and drop style of adding adapter's in my project, now am going down to code everything, when i create a data, adapter, i code them behind. before when i drag and drop the adapter in the form, i could call that adapter in my Button. i have the Following code that i have wrote in my form load
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id= sde; Password=topology;data source= SGIICORNETGS01;persist security info=False;initial catalog=Tshwane_Valuations"
        Dim cn As SqlConnection = New SqlConnection(strconnection)
        cn.Open()
        'set up data adapter 
        Dim strSql As String = _
          "select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _
          & "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1,New_Points_1," _
          & "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence,LS_TYPE from Property_Mass "
        Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)

        'load the Data set

        Dim ds As DataSet = New DataSet
        da.Fill(ds, "Property_Mass")

        'set up data Adapter Object
       


        Dim strErrorMsg As String
        Dim strerror As System.Data.SqlClient.SqlError

        'set up the data soruce 
        
        strSql = _
        "select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _
       & " Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor,Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _
       & " Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _
       & " Property_Summary.Purchase_Date, Property_Summary.Purchase_Price" _
        & " from Property_Mass, Property_Summary" _
        & " where Property_Mass.Lis_key = Property_Summary.Lis_key"
        da = New SqlDataAdapter(strSql, cn)
        'load a Dataset 

        Try
            da.Fill(ds, "Property_Summary")
            '      BindingSource(bindingSource = New BindingSource)

            'Close the Connection
            cn.Close()

            'Create relations 
            ds.Relations.Add("Property_summary_Mass", _
            ds.Tables("Property_Mass").Columns("Lis_key"), _
            ds.Tables("Property_Summary").Columns("Lis_key"))

            'Bind the data set to the grid.
            'Assumes that Grid contains a reference to a 
            'system.windows.datagrid
            DataGrid2.SetDataBinding(ds, "Property_Mass")
            'sorting the Datagrid
            DataGrid2.AllowSorting = True


        Catch ExSQL As System.Data.SqlClient.SqlException
            '''All this will trap all data Problems and Network if available
            For Each strerror In ExSQL.Errors
            Next
            Select Case strerror.Number
                Case 17
                    strErrorMsg = "Missing server"
                Case 4060
                    strErrorMsg = "Missing database"
                Case 18456
                    strErrorMsg = "Missing user name or password"
                Case Else
                    strErrorMsg = strerror.Message
            End Select
            MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)

        Catch ExcpInvOp As System.InvalidOperationException

            MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)

        Catch Excp As System.Exception ' generic exception handler

            MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

This code is working well and it display my dataset results on load. So i have included a Button to Search for a certain Column,but now when i try to use "da" which is the adapter declared in Form load,trying to access it from the button i have placed in my form. it complains about declaration. i understand everything in a form load is Private and the buitton itself is private,

1) how can i declare the adapter and the connection objects to be on the same scope when you drag and drop them on the form?
2)And from my search, am searching from a Field that has (## ## ## ## ##) numbers in a string Field, and i have to rearch by retrieving the first four,i can do that in SQL by using substring, tell me how can i achieve this and display the data in the datagrid.?


Vuyiswa Maseko

AnswerRe: The Scope of the Adapter in the Following code Pin
Dave Kreskowiak31-Jul-07 7:13
mveDave Kreskowiak31-Jul-07 7:13 
Questionmove the toolbar in program Pin
eyes200731-Jul-07 1:29
eyes200731-Jul-07 1:29 
AnswerRe: move the toolbar in program Pin
Tom Deketelaere31-Jul-07 1:46
professionalTom Deketelaere31-Jul-07 1:46 
GeneralRe: move the toolbar in program Pin
eyes200731-Jul-07 2:46
eyes200731-Jul-07 2:46 
GeneralRe: move the toolbar in program Pin
MartyK200731-Jul-07 3:17
MartyK200731-Jul-07 3:17 
GeneralRe: move the toolbar in program Pin
Tom Deketelaere31-Jul-07 3:25
professionalTom Deketelaere31-Jul-07 3:25 
GeneralRe: move the toolbar in program Pin
Tom Deketelaere31-Jul-07 20:59
professionalTom Deketelaere31-Jul-07 20:59 
GeneralRe: move the toolbar in program [modified] Pin
eyes200731-Jul-07 4:22
eyes200731-Jul-07 4:22 
QuestionUpdating a control via a Thread Pin
portech31-Jul-07 1:08
portech31-Jul-07 1:08 
AnswerRe: Updating a control via a Thread Pin
Luc Pattyn31-Jul-07 1:15
sitebuilderLuc Pattyn31-Jul-07 1:15 
QuestionSet focus to a tabpage Pin
Sadiq Parker31-Jul-07 0:40
Sadiq Parker31-Jul-07 0:40 
AnswerRe: Set focus to a tabpage Pin
Christian Graus31-Jul-07 0:47
protectorChristian Graus31-Jul-07 0:47 
GeneralRe: Set focus to a tabpage [modified] Pin
Tom Deketelaere31-Jul-07 1:39
professionalTom Deketelaere31-Jul-07 1:39 
GeneralRe: Set focus to a tabpage Pin
SamRST31-Jul-07 4:12
SamRST31-Jul-07 4:12 
GeneralRe: Set focus to a tabpage Pin
Tom Deketelaere31-Jul-07 4:47
professionalTom Deketelaere31-Jul-07 4:47 
GeneralRe: Set focus to a tabpage Pin
SamRST31-Jul-07 4:13
SamRST31-Jul-07 4:13 
QuestionUrgent connection pooling Pin
viralbhatt30-Jul-07 23:09
viralbhatt30-Jul-07 23:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.