Thanks I shall have a look and let you know how it goes.
Thanks I shall have a look and let you know how it goes.
Hello Ricardo thanks for the explanation and code. very useful and it works :)
Just a few more questions:
Is there a way to display the text in the list box as a string for example each row in the table will be a string in the list box so when its clicked on it can be displayed in the respective text boxes. Also after I have added quite a few activities I get an error message saying index out of bounds.
I put code under the listbox selected index changed but nothing was displayed. and also in the click event but again nothing.
Thanks..
Hi All,
I have a database (sql server) where i store activity information example (activityid,id,summary,signs etc.)
I can successfully save this information to the database. what I also want to achieve is to add this information to a listbox so that it can be displayed in the corresponding textboxes at runtime for an encounterid.
I got an idea but not 100% sure how to go about this; If possible can the steps be explained to me. Code would be appreciated but I'd like to understand it as well.
Thanks..:)
Hey Thank you for the link. very helpful..
Hi all...
I got a stored procedure to compare dates and if the date is not valid it returns an error in sql server.
I need to know how i carry that across to vb.
Thanks..
Hey Managed to make it work, I had too many select statements in there. Thanks for your help. :)
Hey Bhaarat, Thanks for the code but I keep getting errors. So I tried this as well:
create procedure dateCheck
@App_Date datetime
as
select * from Derma_Constultants dc join Appointments app
on dc.ConsultantId=app.ConsultantId
if exists (select * from Derma_Consultants where AvailableStart<=@App_Date and AvailableEnd >= @App_Date)
begin
insert into Appointments(PatientId,P_FName,P_LName,ConsultantName,ConsultantId,@App_Date,AppointmentType
end
go
can you see anything i need to add. this is the error message:
Msg 102, Level 15, State 1, Procedure dateCheck, Line 8
Incorrect syntax near '@App_Date'.
Hello
I want to compare an inserted date against two stored dates in order to validate an entry. The date entered is being stored in a separate table from the stored dates.
I am not sure how to go about this. So far I have this:
create PROCEDURE sp_GetTime
@FullName varchar(50),
@ConsultantId numeric,
@App_Date datetime output
AS
SELECT *
FROM vwPatientConsultantAvailability vw inner Join Appointments app
on vw.ConsultantId = app.ConsultantId
where @FullName=FullName and @ConsultantId=ConsultantId and @App_Date=App_Date
if @App_Date < vw.AvailableStart
I realise I can add if statements to the procedure so if @App_Date between DateA and DateB then validate. if there is a better method please let me know.
Thanks.
hey with some extra help the final code is:
Public Sub RtnCmbVal()
Dim str As String = "select ConsultantId, FullName from Derma_Consultants"
Dim conn As SqlConnection
conn = GetConnection()
conn.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter(str, conn)
Dim dt As New DataTable
da.Fill(dt)
Dim bs As BindingSource = New BindingSource
bs.DataSource = dt
consultantcmb.DataSource = bs
consultantcmb.DisplayMember = "FullName"
consultantcmb.ValueMember = "ConsultantId"
Me.consultantcmb.SelectedValue = -1
End Sub
Private Sub consultantcmb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles consultantcmb.SelectedIndexChanged
If (Not Me.consultantcmb.SelectedValue Is Nothing) Then
Me.ConsultantIdTextBox.Text = consultantcmb.SelectedValue.ToString
End If
End Sub
Thanks for your help! :)
Thanks. But I still cant get it to work. will review my code,might be something in there that is stopping the textbox value from being populated.
Hey I am not too sure how to go about doing this as I have done the following and still the text box is not populated.
ConsultantIdTextBox.DataBindings.Add ("ConsultantId",dset.Tables["Derma_Consultants"],"FullName")
Hello
I am trying to display an ID which is a primary key in my table by selecting the corresponding name in my table. the names have been saved in a combo box and depending on the name selected the textbox will display that Id. the code I have so far only gets the names from sql server but doesnt show the id in the textbox.
can you guide me on this please..
this is the code for combobox. i placed it in the formload
Public Sub RtnCmbVal()
Dim conn As SqlConnection
Dim str As String = "select ConsultantId, FullName from Derma_Consultants"
Dim da As SqlDataReader
conn = GetConnection()
Dim ds As New SqlDataAdapter(str, conn)
Dim cmdGet As New SqlCommand(str, conn)
conn.Open()
da = cmdGet.ExecuteReader
While da.Read
consultantcmb.Items.Add(da("FullName"))
End While
End Sub
@verbalurbs
Do not hijack another thread to ask your question but start your own thread instead.
sorz
Hi Lee
Thanks for your reply I have tried using your method before but never added any code to the click event of the combo box. and I dont think Im sure as to what to add. the options I am getting are the click events for the buttons on the form and when i use that it doesnt give me the result I want.
I am wondering if its because I am selecting fullname first and not the primary key.
Hello
I have a similar issue where I am trying to populate a textbox with a primary key value by selecting a name from a combobox which is stored in sql server.
i have tried different methods and nothing seem to work .
can you guide on this please..
this is the code for combobox. i placed it in the formload
Public Sub RtnCmbVal()
Dim conn As SqlConnection
Dim str As String = "select ConsultantId, FullName from Derma_Consultants"
Dim da As SqlDataReader
conn = GetConnection()
Dim ds As New SqlDataAdapter(str, conn)
Dim cmdGet As New SqlCommand(str, conn)
conn.Open()
da = cmdGet.ExecuteReader
While da.Read
consultantcmb.Items.Add(da("FullName"))
End While
End Sub