Click here to Skip to main content
15,891,033 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: oVideo encryption Pin
Christian Graus25-Nov-07 8:31
protectorChristian Graus25-Nov-07 8:31 
Questionadd column type in datagrid Pin
liat123425-Nov-07 6:12
liat123425-Nov-07 6:12 
AnswerRe: add column type in datagrid Pin
Christian Graus25-Nov-07 8:32
protectorChristian Graus25-Nov-07 8:32 
Questionupdata database from datagrid Pin
liat123425-Nov-07 6:09
liat123425-Nov-07 6:09 
AnswerRe: updata database from datagrid Pin
Vimalsoft(Pty) Ltd25-Nov-07 19:52
professionalVimalsoft(Pty) Ltd25-Nov-07 19:52 
Questiondelete row from data grid Pin
liat123425-Nov-07 6:03
liat123425-Nov-07 6:03 
AnswerRe: delete row from data grid Pin
pmarfleet25-Nov-07 7:01
pmarfleet25-Nov-07 7:01 
AnswerRe: delete row from data grid Pin
John_Adams25-Nov-07 22:54
John_Adams25-Nov-07 22:54 
Hi,

You may try to do this in the following manner.



Dim con As SqlConnection
Dim adap As SqlDataAdapter
Dim ds As New DataSet

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

Dim i As Integer
Dim s As String
Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click

i = DataGrid1.CurrentRowIndex
s = DataGrid1.Item(i, 0)

End Sub

Sub binddata()
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
adap = New SqlDataAdapter("select * from employee", con)
adap.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con = New SqlConnection("server=200.100.100.139;user id=sa;pwd=hello;database=pubs;")
con.Open()
Dim cmd As New SqlCommand
cmd = New SqlCommand("delete from employee where emp_id='" & s & "'", con)
cmd.ExecuteNonQuery()
binddata()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try

End Sub


I hope this helps.


Regards,
John Adams
ComponentOne LLC

QuestionMaskbox select text on focus Pin
nishkarsh_k25-Nov-07 3:24
nishkarsh_k25-Nov-07 3:24 
AnswerRe: Maskbox select text on focus Pin
Christian Graus25-Nov-07 8:33
protectorChristian Graus25-Nov-07 8:33 
QuestionBarcode Pin
Naderrafiee24-Nov-07 22:44
Naderrafiee24-Nov-07 22:44 
AnswerRe: Barcode Pin
Christian Graus24-Nov-07 23:03
protectorChristian Graus24-Nov-07 23:03 
AnswerRe: Barcode Pin
WizardintheWoods25-Nov-07 19:10
WizardintheWoods25-Nov-07 19:10 
QuestionHow can write these two lines? Pin
mehrdadc4824-Nov-07 19:43
mehrdadc4824-Nov-07 19:43 
AnswerRe: How can write these two lines? Pin
MikeMarq24-Nov-07 19:53
MikeMarq24-Nov-07 19:53 
AnswerRe: How can write these two lines? Pin
Christian Graus24-Nov-07 23:04
protectorChristian Graus24-Nov-07 23:04 
Questioncode Pin
trimp24-Nov-07 18:10
trimp24-Nov-07 18:10 
AnswerRe: code Pin
Christian Graus24-Nov-07 18:33
protectorChristian Graus24-Nov-07 18:33 
GeneralRe: code Pin
Paul Conrad24-Nov-07 19:05
professionalPaul Conrad24-Nov-07 19:05 
AnswerRe: code Pin
Paul Conrad24-Nov-07 19:06
professionalPaul Conrad24-Nov-07 19:06 
AnswerRe: code Pin
Mark Churchill26-Nov-07 1:07
Mark Churchill26-Nov-07 1:07 
QuestionVBScript Question Pin
shatterstar645724-Nov-07 14:41
shatterstar645724-Nov-07 14:41 
AnswerRe: VBScript Question Pin
Mycroft Holmes25-Nov-07 15:47
professionalMycroft Holmes25-Nov-07 15:47 
QuestionSaving Serial Port Data To File Pin
crampio24-Nov-07 4:43
crampio24-Nov-07 4:43 
AnswerRe: Saving Serial Port Data To File Pin
Dave Kreskowiak24-Nov-07 12:14
mveDave Kreskowiak24-Nov-07 12:14 

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.