Re: databind to a textbox
As TextBoxes can only hold one value they don't have DataSource and DataBind() attributes.
Try using ExecuteScalar() on the SqlCommand object you create to return just one value and then load it into the TextBox.
Code:
Dim cmdSelect As SqlCommand
cmdSelect = New SqlCommand("SELECT confirm_msg from tb_comp_msg ", oSQLConn)
txt_msg1.Text = cmdSelect.ExecuteScalar().ToString()
Give a shout if you have any problems.
DJ
Re: databind to a textbox
that code rocks :thumb:
i might need it to do more though
when i get stuck ill post back here and edit my title
thanks
Re: databind to a textbox
i want now to go a little deeper,
i want the textbox to display to the current user,
who has logged in using company code column
ie display the message where company code = current user
VB Code:
Dim cmdselect As SqlCommand
cmdselect = New SqlCommand("SELECT msg_default from tb_comp_detail ", oSQLConn)
txtDefault.Text = cmdselect.ExecuteScalar().ToString()
login done on windows forms and msg_default is in the same table as companycode