Hey Guys i need to copy value from table to onther table in same data base like.. My program is to Add Silk Or Money into database by the user write the username into textbox1 and the amount of silk or money into textbox2 and the record need a value from onther database i need to find that value from Username.. need JID i need to Get JID From StrUSerID Then Put the the JID Into onther table by write the StrUserID into textbox1 and amount silk or money into textbox2 then put it here but i got dat error Insert into data code: Query = "insert into SK_Silk (JID,silk_own) Values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "') Select JID From TB_User where JID='" & TextBox1.Text & "'" full code: Imports System.Data.SqlClient
Public Class addsilk
Public mysqlconn As SqlConnection
Public command As SqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mysqlconn = New SqlConnection
mysqlconn.ConnectionString = "Data Source=" + Form2.txtServerName.Text + ";initial catalog=" + Form2.txtdatabasename.Text + ";user id=" + Form2.textusername.Text + ";password=" + Form2.txtpassword.Text
Dim reader As SqlDataReader
Try
mysqlconn.Open()
Dim Query As String
Query = "insert into SK_Silk (JID,silk_own) Values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "') Select JID From TB_User where JID='" & TextBox1.Text & "'"
command = New SqlCommand(Query, mysqlconn)
reader = command.ExecuteReader
' NotifyIcon1.ShowBalloonTip(1000, "Information", "Has Been added Silk To" & TextBox2.Text, ToolTipIcon.Info)
NotifyIcon1.ShowBalloonTip(1000, "Information", " Has Been Add " & TextBox2.Text & " Silk To " & TextBox1.Text, ToolTipIcon.Info)
'MessageBox.Show(" Has Been Added " & TextBox2.Text & " Silk To Username " & TextBox1.Text)
mysqlconn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
|