Click here to Skip to main content
15,883,819 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Datacombo1 Highlighted serched item Pin
Dave Kreskowiak8-Mar-09 5:44
mveDave Kreskowiak8-Mar-09 5:44 
QuestionDataset Pin
md_refay6-Mar-09 20:28
md_refay6-Mar-09 20:28 
AnswerRe: Dataset Pin
Rupesh Kumar Swami7-Mar-09 3:58
Rupesh Kumar Swami7-Mar-09 3:58 
Question[Message Deleted] Pin
vinmaac6-Mar-09 19:23
vinmaac6-Mar-09 19:23 
AnswerRe: KEYLOGGER Pin
Garth J Lancaster6-Mar-09 19:49
professionalGarth J Lancaster6-Mar-09 19:49 
QuestionPlaying Wave files with the Audio routines? Pin
TheComputerMan6-Mar-09 14:16
TheComputerMan6-Mar-09 14:16 
AnswerRe: Playing Wave files with the Audio routines? Pin
TheComputerMan6-Mar-09 14:35
TheComputerMan6-Mar-09 14:35 
Questionmy vb.net code Pin
JAYRAJ GIRI6-Mar-09 8:24
JAYRAJ GIRI6-Mar-09 8:24 
Public Class Form12
Dim ds As New DataSet
Dim da As New SqlClient.SqlDataAdapter

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CN As New SqlClient.SqlConnection
CN.ConnectionString = "Data Source=homepc\sqlexpress;Initial Catalog=Northwind;Integrated Security=True"

Dim cmd As New SqlClient.SqlCommand
cmd.Connection = CN
cmd.CommandText = "Select * From Customers"

da.SelectCommand = cmd

da.Fill(ds, "Customers")

da.Fill(ds, "CustomersDummy")

Dim PK(0) As DataColumn
PK(0) = ds.Tables("Customers").Columns("CustomerId")
ds.Tables("Customers").PrimaryKey = PK


MsgBox("ok")

Me.DataGridView1.DataSource = ds
Me.DataGridView1.DataMember = "Customers"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox(Me.ds.Tables.Count)

Me.ComboBox1.Items.Clear()
For Each tbl As DataTable In ds.Tables
Me.ComboBox1.Items.Add(tbl.TableName)
Next

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim tbl As DataTable = ds.Tables(Me.ComboBox1.SelectedItem)
Me.ComboBox2.Items.Clear()
For Each col As DataColumn In tbl.Columns
Me.ComboBox2.Items.Add(col.ColumnName)
Next

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim tbl As DataTable = ds.Tables(Me.ComboBox1.SelectedItem)
Dim Ans As String = ""
For Each dr As DataRow In tbl.Rows
Ans &= dr.Item(Me.ComboBox2.SelectedItem) & ", "
Next
MsgBox(Ans)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim dr As DataRow
Dim Str As String = InputBox("Enter Customerid")

dr = ds.Tables("Customers").Rows.Find(Str)
If dr Is Nothing Then
MsgBox("Not found...")
Exit Sub
End If

MsgBox(dr.Item("ContactName") & "-" & dr.Item("Country"))

dr.BeginEdit()
dr.Item("ContactName") = "Mr. " & dr.Item("ContactName")
dr.Item("Country") = dr.Item("Country").ToString.ToUpper
dr.EndEdit()

MsgBox(dr.Item("ContactName") & "-" & dr.Item("Country"))

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim dr As DataRow
For Each dr In ds.Tables("Customers").Rows
dr.BeginEdit()
dr.Item("Country") = dr.Item("Country").ToString.ToUpper
dr.EndEdit()
Next
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim dr, drs() As DataRow
drs = ds.Tables("Customers").Select("Country = 'UK'")
For Each dr In drs
dr.BeginEdit()
dr.Item("ContactName") = dr.Item("ContactName").ToString.ToUpper
dr.EndEdit()
Next
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim Row As DataRow
Row = ds.Tables("Customers").NewRow
Row.BeginEdit()
Row.Item("CustomerId") = "SAMIR"
Row.Item("ContactName") = "ABC"
Row.Item("ContactTitle") = "XYZ"
Row.Item("Country") = "INDIA"
Row.EndEdit()

ds.Tables("Customers").Rows.Add(Row)


End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim dr As DataRow
Dim Str As String = InputBox("Enter Customerid")

dr = ds.Tables("Customers").Rows.Find(Str)
If dr Is Nothing Then
MsgBox("Not found...")
Exit Sub
End If

dr.Delete()
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim Criteria As String = "Country = 'UK'"
Dim Ans As Integer
Ans = ds.Tables("Customers").Compute("Count(CustomerId)", Criteria)
MsgBox(Ans)
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim Criteria As String = "Country Like '" & Me.TextBox1.Text & "*'"

Dim dv As DataView

dv = ds.Tables("Customers").DefaultView
dv.RowFilter = Criteria

Me.DataGridView1.DataSource = dv
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
Dim CN As New SqlClient.SqlConnection
CN.ConnectionString = "Data Source=homepc\sqlexpress;Initial Catalog=Northwind;Integrated Security=True"

Dim StrSql As String
StrSql = "Update Customers Set Country = Upper(Country) "
StrSql &= " Where Country = 'UK'"

Dim cmd As New SqlClient.SqlCommand
cmd.Connection = CN
cmd.CommandText = StrSql

Try
CN.Open()
cmd.ExecuteNonQuery()
MsgBox("Ok")
Catch ex As Exception
MsgBox(ex.Message)
Finally
CN.Close()
End Try



End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Dim CN As New SqlClient.SqlConnection
CN.ConnectionString = "Data Source=homepc\sqlexpress;Initial Catalog=Northwind;Integrated Security=True"

Dim StrSql As String
StrSql = "Select Count(*) From Customers"

Dim cmd As New SqlClient.SqlCommand
cmd.Connection = CN
cmd.CommandText = StrSql

Dim Ans As Integer
Try
CN.Open()
Ans = cmd.ExecuteScalar
MsgBox(Ans)
Catch ex As Exception
MsgBox(ex.Message)
Finally
CN.Close()
End Try

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim CN As New SqlClient.SqlConnection
CN.ConnectionString = "Data Source=homepc\sqlexpress;Initial Catalog=Northwind;Integrated Security=True"

Dim StrSql As String
StrSql = "Select * From Customers"
StrSql &= " Where Country = 'UK'"


Dim cmd As New SqlClient.SqlCommand
cmd.Connection = CN
cmd.CommandText = StrSql


Dim dr As SqlClient.SqlDataReader
Dim Ans As String

Try
CN.Open()
dr = cmd.ExecuteReader
Do While dr.Read
Ans &= dr.Item("CustomerId") & ", "
Loop
MsgBox(Ans)
Catch ex As Exception
MsgBox(ex.Message)
Finally
dr.Close()
CN.Close()
End Try

End Sub

Private Sub Form12_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class
GeneralRe: my vb.net code Pin
Luc Pattyn6-Mar-09 8:32
sitebuilderLuc Pattyn6-Mar-09 8:32 
GeneralRe: my vb.net code Pin
Christian Graus8-Mar-09 17:11
protectorChristian Graus8-Mar-09 17:11 
AnswerRe: my vb.net code Pin
Dave Kreskowiak6-Mar-09 9:26
mveDave Kreskowiak6-Mar-09 9:26 
QuestionRe: my vb.net code Pin
dan!sh 6-Mar-09 20:53
professional dan!sh 6-Mar-09 20:53 
QuestionChange file extention association and apply changes? Pin
Member 21389206-Mar-09 5:00
Member 21389206-Mar-09 5:00 
AnswerRe: Change file extention association and apply changes? Pin
Dave Kreskowiak6-Mar-09 5:35
mveDave Kreskowiak6-Mar-09 5:35 
GeneralRe: Change file extention association and apply changes? Pin
Member 21389208-Mar-09 21:32
Member 21389208-Mar-09 21:32 
GeneralRe: Change file extention association and apply changes? Pin
Dave Kreskowiak9-Mar-09 2:15
mveDave Kreskowiak9-Mar-09 2:15 
Questionlink for merger module for CR Pin
hrishiS6-Mar-09 2:32
hrishiS6-Mar-09 2:32 
AnswerRe: link for merger module for CR Pin
Dave Kreskowiak6-Mar-09 4:17
mveDave Kreskowiak6-Mar-09 4:17 
QuestionCrystal Reports Parameter problem Pin
Jay Royall6-Mar-09 1:44
Jay Royall6-Mar-09 1:44 
QuestionUsercontrol focus Pin
JR2126-Mar-09 0:54
JR2126-Mar-09 0:54 
AnswerRe: Usercontrol focus Pin
Eddy Vluggen6-Mar-09 1:15
professionalEddy Vluggen6-Mar-09 1:15 
GeneralRe: Usercontrol focus Pin
JR2129-Mar-09 4:28
JR2129-Mar-09 4:28 
GeneralRe: Usercontrol focus Pin
Eddy Vluggen9-Mar-09 6:07
professionalEddy Vluggen9-Mar-09 6:07 
GeneralRe: Usercontrol focus Pin
JR2129-Mar-09 21:16
JR2129-Mar-09 21:16 
GeneralRe: Usercontrol focus Pin
Eddy Vluggen9-Mar-09 23:21
professionalEddy Vluggen9-Mar-09 23:21 

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.