开发者

datareader to read a data from database filter and show in textbox

开发者 https://www.devze.com 2023-03-01 13:35 出处:网络
Hi Friend i have a form with one combobox and textbox now on other hand i have a sql database na开发者_JS百科med balance with two column one as customername and and another as obbalance now i had

Hi Friend i have a form with one combobox and textbox now on other hand i have a sql database

na开发者_JS百科med balance with two column one as customername and and another as obbalance now i had

binded all the customer name to the combobox now what i have to do is wen user selects a

customername from the combobox the textbox should show the obbalance of the selected

customername can u help me out ........send me the code plz


Your question isn't very clear, but I'll give it a shot. This assumes you are using an SQL database and that customername is unique in the balance table.

Using conn As New SqlConnection("YourConnectionString"), _
      command As New SqlCommand("SELECT obbalance from _
      balance where customername=@customername)

      command.parameters.add("@customername", SqlDbType.Char)

      command.parameters("@customername").value = "CustomerNameFromTextBox"

      Dim obbalance As Decimal = CDec(command.ExecuteScalar)

End Using

You need to replace "YourConnectionString" with a real connection string that will be specific to your database. Replace "CustomerNameFromTextBox" with the name that was selected in your customer text box. You will probably also need to change the data types for obbalance and the @customername parameter to match the data types in your database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号