Jump to content

jassticky

Members
  • Posts

    1
  • Joined

  • Last visited

About jassticky

  • Birthday 04/30/1990

Previous Fields

  • Languages
    Dot Net,Sql,Php,Mysql,

Contact Methods

  • Website URL
    http://thisisdotnet.blogspot.in
  • Skype
    suniljas

Profile Information

  • Location
    Chennai
  • Interests
    Online Games,Web designing,Blogging

jassticky's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hey rony,This is the concept to insert into database for 2 entries . We have to keep one column as primary key and using for loop we can achive this. Using this concept you can do n number of columns insertion. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str3 Try Dim str2 As String Dim count As Integer If (DataGridView1.Rows.Count > 0) Then For i As Integer = 0 To DataGridView1.Rows.Count - 2 str2 = "select count (*) from userinfo where userid = '" + DataGridView1.Rows(i).Cells(0).Value + "'" str3 = New SqlCommand(str2, con) con.Open() count = str3.ExecuteScalar con.Close() If (count = 0) Then Dim sqlcmd = New SqlCommand("insert into userinfo values('" + DataGridView1.Rows(i).Cells(0).Value + "','" + DataGridView1.Rows(i).Cells(1).Value + "')", con) sqlcmd.CommandType = CommandType.Text con.Open() sqlcmd.ExecuteNonQuery() con.Close() End If Next MsgBox("no records found to be inserted") End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub
×
×
  • Create New...