Hey Guys i need to copy value from table as integer 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 Which From Username can get his JID then insert into Direct
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
Click Here
then put it here
Click Here
but i got dat error
Click Here
insert query 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
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.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 = "ALTER TABLE TB_User ADD CONSTRAINT UQ_StrUserID_ID UNIQUE "
'Query = "ALTER TABLE TB_User ADD CONSTRAINT UQ_USER_ID UNIQUE (StrUserID)"
'Query = "Update TB_User set StrUserID='" & TextBox1.Text & "' ,passwod='" & TextBox2.Text & "' where StrUserID='" & TextBox1.Text & "'"
'Query = "insert into SK_Silk (JID,silk_own) Values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "')"
Query = "Update SK_Silk set JID='" & TextBox1.Text & "' ,silk_own='" & TextBox2.Text & "' where JID='" & TextBox1.Text & "'"
' Query = "insert into TB_User (StrUserID,password) Values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "')"
'Query = "Alert TB_User ADD CONSTRAINT UQ_StrUserID_UNIQUE ('" & TextBox1.Text & "' , '" & TextBox2.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 Update " & 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
End Class