parse the value into datagrid?

sphericalx

New member
Joined
Sep 7, 2008
Messages
3
Programming Experience
1-3
i have tried using the code u provided, however i encountered a error while debugging and below is the error msg.

"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

anyway, i'm using vb 2005 express edition & sql server 2000.

VB.NET:
Expand Collapse Copy
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim str_sql_user_select As String = "SELECT * FROM client"
    Dim str_connection As String = "Data Source=local;User ID=myid;Password=mypwd;Initial Catalog=FinBank"
    Dim mycon As SqlConnection
    Dim comUserSelect As SqlCommand
    Dim myreader As SqlDataReader
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mycon = New SqlConnection(str_connection)
        'Instantiate the commands
        comUserSelect = New SqlCommand(str_sql_user_select, mycon)
        TextBox1.Text = " "
        TextBox2.Text = " "
        mycon.Open()
        myreader = comUserSelect.ExecuteReader
        If (myreader.Read = True) Then
            TextBox1.Text = myreader(0)
            TextBox2.Text = myreader(1)
        Else
            MsgBox("You have reached eof")
        End If
    End Sub
End Class

thanks,

ron


i have manage to get it working alr.

[original]Dim str_connection As String = "Data Source=local;User ID=myid;Password=mypwd;Initial Catalog=FinBank

[changed]Dim str_connection As String = "Data Source=127.0.0.1;User ID=myid;Password=mypwd;Initial Catalog=FinBank

anyway, anyone know how to parse the value into datagrid?
 
Last edited:
opps.. pasted the wrong coding into the post. below then is the right one. =x

VB.NET:
Expand Collapse Copy
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim SQLstr As String
    Dim str_connection As String = "Data Source=127.0.0.1;Integrated Security=SSPI;Initial Catalog=FinStudio;User Id=myuserid;Password=mypw"
    Dim mycon As SqlConnection
    Dim comUserSelect As SqlCommand
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToScreen()
        SQLstr = "SELECT * FROM CUSTOMERS"
        mycon = New SqlConnection(str_connection)
        comUserSelect = New SqlCommand(SQLstr, mycon)
        Dim dataadapter As SqlDataAdapter = New SqlDataAdapter(comUserSelect)
        Dim ds As DataSet = New DataSet()
        '---open the connection and fill the dataset---
        mycon.Open()
        '---fill the dataset---
        dataadapter.Fill(ds, "Customers_table")
        '---close the connection---
        mycon.Close()
        '---bind to the DataGridView control---
        DataGridView1.DataSource = ds
        '---set the table in the dataset to display---
        DataGridView1.DataMember = "Customers_table"
        DataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders
    End Sub

anyway, is it possible that when the user select a certain cells in the datagridview, that row of cells get highlighted and when they double-click on it, a panel will appear.

thanks,

ron
 
I'm not sure what you mean by parse in this situation and I don't see a datagrid in your code.

I would recommend watching the Visual Basic How Do I Video Series video series (at least the first 3 videos) to see how Visual Studio will do all the work for you.

anyway, i dun tink the links is applicable for me because i ain't using sql server express edition, thus there are alot of functions not available. ^^
 
anyway, i dun tink the links is applicable for me because i ain't using sql server express edition, thus there are alot of functions not available. ^^

Funny, I ain't using SQL Server Express Edition either but the concepts still apply.

anyway, is it possible that when the user select a certain cells in the datagridview, that row of cells get highlighted and when they double-click on it, a panel will appear.

VB.NET:
Expand Collapse Copy
	Private Sub DataGridView1_CellEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
	Handles DataGridView1.CellEnter

		'If user selects a cell in the first column the entire row is selected
		If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
			Me.DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Selected = True
		End If

	End Sub

	Private Sub DataGridView1_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
	Handles DataGridView1.CellDoubleClick

		'Check which column the cell is in
		'Code to open your panel

	End Sub
 
Back
Top