poojavb 29 Junior Poster

I am not sure how ur Handling application for all clients. If application users are more in number its allways good to publish the application and place in server. However in ur case go to publish wizard select preRequisites and add ur framework so it will get placed in debug folder when u build the ap and it will refer from root path.

I guess u did not get my question....

I am able to start my application and I dont actually want to publish it....it is a client side project no need of server....

It will be installed in one machine only at a time....

My problem is that...when the client will execute the exe file given to him....the .net framework wont be updated in his machine which is placed on the below path

C:\Windows\Microsoft.NET\Framework

I want the startup process in such a way that when I click on the exe file it should check if the framework is updated else update the framework...

So I need to know how to proceed...

for eg...when we install any java related exe file...it always checks whether java and jdk is present in our machine else it will prompt the user that it is not installed and we need to istall it...and it starts the installation...same way i need for vb.net

poojavb 29 Junior Poster

What I'm trying to do is have a login type windows form to take a user name and password then compare these with data in the db then open an admin type form. I've been trying to get this to work for a few days now with no luck, about 90% of the code below is a peice together from various forums trying to get it to work.

i no longer get an error 26 connection cant be made or what may have you, but now i get "Login failed for user ''.", not quite should what this means or how to go about it

Private Sub LoginB_Click(sender As System.Object, e As System.EventArgs) Handles LoginB.Click
        Try
            Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;Database=C:\tcdb\tcdb.sdf;")
            Dim cmd As New SqlCommand("SELECT Username, Password FROM(Users) WHERE (Username = '" & UserTXT.Text & "') AND (Password = '" & PassTXT.Text & "')", con)
            con.Open()
            Dim sdr As SqlDataReader = cmd.ExecuteReader()
            ' If the record can be queried, it means passing verification, then open another form.   
            If (sdr.Read() = True) Then
                MessageBox.Show("The user is valid!")
                Admin.Show()
                Me.Hide()
            Else
                MessageBox.Show("Invalid username or password!")
            End If
            con.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

ps. sdf db has no user/pass needed to open... i think
i didnt set one and the whole app doesnt use one and loads binded data within another form without any problem whatsoever

thanks in adv

Try to open the connection before the SQL query....

u have opened the connection after the query

poojavb 29 Junior Poster

Hi guys well what I'm trying to do is produce a query that only produces the results which will match my director input. I have looked for the correct syntax and cannot seem to find it.

Any help would be appreciated

Code of my syntax below:

ResultSet results = myStatement.executeQuery
                        ("SELECT VIDEOID, VIDEONAME, DIRECTOR FROM VIDEOS");
                while (results.next()) {

                }

Check if the connection is created to the database

Connection con;
Statement stmt=con.createStatement();
ResultSet rs=null;

String ss=("SELECT VIDEOID, VIDEONAME, DIRECTOR FROM VIDEOS");
rs=stmt.executeQuery(ss); 
while(rs.next())
{
//code goes here
}
poojavb 29 Junior Poster

Are you using any packging tools or ur using Publish wizard in visual studio?.

When we create a project the .exe file gets created in the Debug folder....so I am using the .exe file itself

poojavb 29 Junior Poster

thankyou for your reply. I have a bit of a problem though :P

What will be the command to get in between dates? my current code is

"SELECT * FROM tablename WHERE orderDate BETWEEN (Format([orderDate], 'Short Date'))= '" + dtpFrom.Value.Date + "' AND (Format([orderDate], 'Short Date'))= '" + dtpTo.Value.Date + "'"

This doesn't seems to work.. any error on my sql?

"SELECT * FROM tablename where (Format([orderDate], 'Short Date'))  between '" + dtpFrom.Value.Date + "' and '" + dtpTo.Value.Date + "'"

Mark thread as solved if it helped u.... :)

poojavb 29 Junior Poster

What is ur way of deployement?

Sorry I did not get ur question....

poojavb 29 Junior Poster

Hello Friends,

Please help me in this....

I have created a project in VB.net and its working fine in my machine.

But when I provide the exe to my senior to test it shows the initialization error.

I came to know the reason that the error is because the microsoft .net framework is not updated in my seniors machine....

So there can be a possibility that the framework might not be updated on the client's machine as well....

So can anyone give me an idea as to when the user clicks on the exe file it should check that the microsoft framework is present and updated if not then the exe file should first prompt the user that the microsoft framework is needed and should be updated and start the installation....

I dont know if u all understood what I need...but please if anyone knows then please help me....

thanks in advance

poojavb 29 Junior Poster

Hello Friends,

I need an urgent help on the below topic....

I have created a project which takes the database dyanamically....

Means when the application starts it will ask for the database path....the database will already be created in some or the other folder....

The path for database is stored in one text file....

It is an access database....

While creating crystal report I had created the report using the database....but that became static...and the report is not able to fetch the records since it is not getting the database

Now I want that while the application runs....a connection should be set up to the dyanamic database path and the report should be viewed....

Please help me in this....

Help me to understand how shud I create the database connection for crystal report in vb.net

I had to copy the reports folder also...

poojavb 29 Junior Poster

Hello Friends,

I need an urgent help on the below topic....

I have created a project which takes the database dyanamically....

Means when the application starts it will ask for the database path....the database will already be created in some or the other folder....

The path for database is stored in one text file....

It is an access database....

While creating crystal report I had created the report using the database....but that became static...and the report is not able to fetch the records since it is not getting the database

Now I want that while the application runs....a connection should be set up to the dyanamic database path and the report should be viewed....

Please help me in this....

Help me to understand how shud I create the database connection for crystal report in vb.net

poojavb 29 Junior Poster

But i prefer to have primary key as integer not as text or varchar. indexing will be done on primary key if it is text performance will go down. U can have one more column in whci u can save the data Doc1,Doc2 etc..

I have posted for getting the string Doc1 and Doc2......and so on....

poojavb 29 Junior Poster

hello!
in you db , date format is same as you specified in your windows , so change the date format .secondly users have concern with the interface , time showing on there datetime picker , there you can set the format property custom and set your required format of date

Regards

Try this

Dim date1 As String
        date1 = DateTimePicker1.Value.ToString("MM-dd-yyyy")

while inserting insert only the date1 variable

to get it from database try this

"SELECT * FROM tablename WHERE (Format([Fieldname], 'Short Date'))= '" + DateTimePicker1.Value.Date + "'"
poojavb 29 Junior Poster

try this code from sql server - vb.net

Private Sub loddatagrid()
        Call main()
        Con.Open()

        DataAdapter1 = New SqlDataAdapter("SELECT [ID],[type],[lot],[loc],[meas],[units],[pounds] FROM [dbo].[Inventory] where [rcvandwork]='" & txt1.Text & "'", Con)
        DataSet1.Clear()
        DataAdapter1.Fill(DataSet1, "Table1")

        grid1.DataSource = DataSet1
        grid1.DataMember = "Table1"
        grid1.Refresh()
        Con.Close()
    End Sub

private sub form....
loddatagrid()
        txtno.DataBindings.Add("Text", DataSet1, "Table1.ID")
        xt1.DataBindings.Add("Text", DataSet1, "Table1.type")
        xt2.DataBindings.Add("Text", DataSet1, "Table1.lot")
        xt3.DataBindings.Add("Text", DataSet1, "Table1.loc")
        xt4.DataBindings.Add("Text", DataSet1, "Table1.meas")
        xt5.DataBindings.Add("Text", DataSet1, "Table1.units")
        xt6.DataBindings.Add("Text", DataSet1, "Table1.pounds")
end sub

check this...I have done this and it has worked....

Dim i As Integer
        Dim DocID As String
        i = dgvDocSearch.CurrentRow.Index
        DocID = dgvDocSearch.Item(0, i).Value ' selects the first column of the row....
              'Connection string goes here 
        Try
            Dim myCommand As OleDbCommand

            myCommand = New OleDbCommand("SELECT DoctorID As ID ,(FirstName+' '+ LastName) as DoctorName  FROM DoctorRegister where DoctorID='" & DocID & "'", Connection) 'according to ur DocID it will take the value from database and display it in ur text box

            Dim reader As OleDbDataReader = myCommand.ExecuteReader
            While reader.Read
                Textboxname.Text = DocID
             
            End While
        Catch ex As Exception
            MsgBox("Error Connecting to Database: " & ex.Message)
        End Try
    'Close connection

this code has to be wriiten in datagrid cell click event
poojavb 29 Junior Poster

You can create a naming scheme, which you already have. Then generate that name on runtime. I am assuming you are using a database backend?

If so, you can use a primary key as a varchar. Generate the key in application, on save, by:

dim datestr as string = today.year & today.month & today.day & today.second 'varries on your creation time.
'Will create a string = "2012020935"

Please try the below....

Dim TLDateTime As String
Dim TLDay As String
Dim TLMonth As Integer
Dim TLYear As Integer
TLDay = DateTime.Now.Day
TLMonth = DateTime.Now.Month
TLYear = DateTime.Now.Year
Dim MyDate As New DateTime(TLYear, TLMonth, TLDay)
Dim MyString As String = MyDate.ToString("ddMMyy")
TLDate = TLMonth.ToString + TLDay.ToString + TLYear.ToString
Dim receiptid as String
receiptid=Textbox.Text ' which will have the receipt id
TLDateTime = TLDate  + receiptid
poojavb 29 Junior Poster

Forgot the one thing to find the length of ID there only easy when you add 10,11...,100,101,....,1000,1001...

temp_id=string.Empty;
for(int i=0;i<(5-id.lenth);i++)
{
 temp_id+="0";
}
temp_id+=id;

I have done the following to get the custom ids like DOC1, DOC2, DOC3 and so on....

I have create a table which will store the number in it....

and the master table will just save the value in database with string

eg.

I have a table as IDvalues with one field that is DOCValue and datatype number with value 1

in the DOctormaster table I have the ID field as the primary key and datatype as text....

when I click on save I first take the max value from IDvalues table and the value is appended with "DOC" string and saved in Doctormaster table as DOC1.....

Soon after saving I have incremented the value in IDvalue by 1.....

I have done it this way since when I had created a field as ID in doctormaster table with datatype as Text it used to get appended correctly till DOC10 but after that it showed problem....

So I opted for this long but safe method....

U can give it a try....even if u dont get it....just post again....

poojavb 29 Junior Poster

just want to know how will i able to display the info description in my list view but the one that appears in the database is its id(using vb.net)

The id value must be having some description in ur table right??
if yes then use the below code. I quess it will help

'Database connection
Dim strSQL As String = "SELECT distinct ID,Name FROM TableName"
Dim da As New OleDbDataAdapter(strSQL, Connection)
Dim ds As New DataSet
da.Fill(ds, "TableName")
        With ListViewName
            .DataSource = ds.Tables("TableName")
            .DisplayMember = "Name"
            .ValueMember = "ID"
        End With
poojavb 29 Junior Poster

Yes...

DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm:ss");

But how do I include the miliseconds (and the localized version of the day of the week)?

Check this

Dim MyTime As String
MyTime = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff")

It gives the output:
09-Feb-2012 18:08:14.403

Sorry its in vb.net

poojavb 29 Junior Poster

you can try this too...

http://www.codeproject.com/Articles/9307/Converting-WinForms-Web-Forms-using-CodeDom

Thank u all for ur reply....

I guess I will have to manually do the coding....

poojavb 29 Junior Poster

No dude there is any Conversion tool to VB.net to asp.net We only have VB.net to C# net tool so keep your work to done

Ohhhh my badluck....thanks for ur reply

poojavb 29 Junior Poster

Yup you are right, asp.net can use vb.net and c#, maybe what he was trying to ask is from windows app to asp.net.. because asp.net is just a framework that could use different oop languages..

Let me explain...

Few months ago I had started with a project in VB.Net i.e. Windows Framework but now my Manager is saying that he dont want VB.Net instead he want the project to be in ASP.net and I am not finding it easy to code is ASP.Net.

So I was just asking whether is there any tool that will convert my VB.Net coding to ASP.Net.

poojavb 29 Junior Poster

Here, try this link for conversion.

http://www.developerfusion.com/tools/convert/vb-to-csharp/

Actually I need to convert vb.net code to Asp.Net

poojavb 29 Junior Poster

Hello All,

Actually I am facing issue in creating an ASP.net application.

I have created a project in VB.net but now my seniors are saying that the code should be in ASP.net and it is taking hell lot of time for code conversion, designing and all other stuff.

Actually I am not able to get all the functions and properties in ASP.Net since I had been working in ASP.Net for a long time.

Is there any simple way of code conversion...any tool or such?

Thanks in Advance.

poojavb 29 Junior Poster

Hello All,

Actually I am facing issue in creating an ASP.net application.

I have created a project in VB.net but now my seniors are saying that the code should be in ASP.net and it is taking hell lot of time for code conversion, designing and all other stuff.

Actually I am not able to get all the functions and properties in ASP.Net since I had been working in ASP.Net for a long time.

Is there any simple way of code conversion...any tool or such?

Thanks in Advance.

poojavb 29 Junior Poster

Okay, I implemented the changes that you suggested, and VS 2010 now tells me that it is expecting an end of statement at the

combobox3.text & "'"

I don't understand what it means.....

This is the update Query with the changes in it

Query = "update Prod_DB_Completed_Board set [Stock Level] = '" & TextBox2.Text & "' where Laminate = '" & ComboBox2.Text & "'" & "and where [Board Size] = " & "'" ComboBox3.Text & "'"

No need to add the where twice

Query = "update Prod_DB_Completed_Board set [Stock Level] = '" & TextBox2.Text & "' where Laminate = '" & ComboBox2.Text & "' and  [Board Size] = '" & ComboBox3.Text & "'"

This will help u

poojavb 29 Junior Poster

im a beginner wid vb .net and need to clear the air wid connecting a database file created on sql server 2008r2 wid vb.net 2008 for a project..plz nebody help from scratch regardng retriving,insertng n modifyng data using vb.net code..awaiting....

u can create a module and call it every time u need a connection

Imports System.Data.SqlClient

Module DBConnection
    Public Connection As SqlConnection = New SqlConnection()
    Public Function Open_DB_Connection() As String
        Try
            Connection.ConnectionString = "Server=.\SQLEXPRESS;" & _
                    "Database=DBName;Trusted_Connection=True"
            Connection.Open()
            Return "Success"
        Catch ex As Exception
            Debug.Print(ex.Message & "in DBConnection_Module")
            Return "Fail"
            Exit Function
        End Try
    End Function

    Public Function Close_DB_Connection() As String
        Try
            Connection.Close()
            Return "Success"
        Catch ex As Exception
            Debug.Print(ex.Message & "in DBConnection_Module")
            Return "Fail"
            Exit Function
        End Try
    End Function
End Module

calling DB connection in ur forms

Dim Open_DB_Con As String
Open_DB_Con = Open_DB_Connection()

--your SQl query part goes here

Dim Close_DB_Con As String
Close_DB_Con = Close_DB_Connection()
poojavb 29 Junior Poster

U can try this too for a alphanumeric or if u need only numeric increment then delete the red part

Try
            Dim myCommand As SqlCommand
            Dim STid As String
            myCommand = New SqlCommand("select ISNULL(Max(SUBSTRING(id,4,7)),0) From Studentreg", Connection)
            Dim reader As SqlDataReader = myCommand.ExecuteReader
            reader.Read()
            STid= reader.Item(0) + 1
            Textbox1.Text = "ST" +  STid.ToString()
            reader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

use this for numeric increment...the datatype in database should be an integer

Try
            Dim myCommand As SqlCommand
            Dim STid As String
            myCommand = New SqlCommand("select MAX(ID) From Studentreg", Connection)
            Dim reader As SqlDataReader = myCommand.ExecuteReader
            reader.Read()
            STid= reader.Item(0) + 1
            Textbox1.Text = STid.ToString()
            reader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
poojavb 29 Junior Poster

Have you tried the .ToString() function?

Example...

TxtRate.Text = dt.Rows(0).Item(1).ToString

Try this...

Dim conn As New SqlConnection(ConnectionString)
        Dim abc As String
        abc= cbMenu.Text 'the value selected in combo box       
        Dim strSQL As String = "select Menu_Rate from Menu where Menu_Name='" & abc & "'"
        Dim da As New SqlDataAdapter(strSQL, conn)
        Dim ds As New DataSet
        da.Fill(ds, "Menu")
        With txtRate ' your text box name
            .DataSource = ds.Tables("Menu") 'your table name            
            .DisplayMember = "Menu_Rate"
          '  .ValueMember = "ProductID"
        End With
poojavb 29 Junior Poster

ok thank you, i will try this

U can try this too for a alphanumeric or if u need only numeric increment then delete the red part

Try
            Dim myCommand As SqlCommand
            Dim STid As String
            myCommand = New SqlCommand("select ISNULL(Max(SUBSTRING(id,4,7)),0) From Studentreg", Connection)
            Dim reader As SqlDataReader = myCommand.ExecuteReader
            reader.Read()
            STid= reader.Item(0) + 1
            Textbox1.Text = "ST" +  STid.ToString()
            reader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
poojavb 29 Junior Poster

Hello All,

I need help in this...

I am attaching a zip file which contains my project in Microsoft Visual Studia 2010 along with Crystal reports....

Please help me....its giving a lot of errors...and I dont know from where it is coming and why....

Urgent help....

Change the Project prperties from .Net Framework 4 Client prfoile to .Net Framework 4

poojavb 29 Junior Poster

Hello All,

I need help in this...

I am attaching a zip file which contains my project in Microsoft Visual Studia 2010 along with Crystal reports....

Please help me....its giving a lot of errors...and I dont know from where it is coming and why....

Urgent help....

poojavb 29 Junior Poster

I know to work with VB.net + crystal report + SQL server.
But now i want to work with SQL server compact edition instead of SQL server.
When we creating Crystal report it is asked provider in one moment. If we work with SQL server we select "Microsoft OLE DB provider for SQL server".
I want to know

(Q1) what I should select as provider.

(Q2)After clicking next, it is asked SERVER. what should i typed. (When i use sql server i typed, "MyName-PC\SQLEXPRESS")

Please Help Me.....

If its a windows authentication in ur SQL server then u can use as follows

Server Name: MyName-PC\SQLEXPRESS

Integrated Sercurity checkbox as checked

then the username and password gets disabled

click on Database... ur database will come in the drop down....

poojavb 29 Junior Poster

Hello Friends,

I need to create a report for my project

I am using Miscrosoft Visual Studio 2010 and the SAP crystal Report

I am not able to set up the connection

The SQL server that I am using is not coming in the drop down of the server part in crystal report

and it is a windows authentication so no password....

when I am filling all the details the drop down is not getting loaded with the database name....

Can anyone help me with the connection....

Thanks....

The code which u have given is for vb.net database connectivity....

I needed it for crystal reports...

Anyways...i got my problem solved....

Thank u....

poojavb 29 Junior Poster

The code did not work..

Its showing error as dt is not a member of DataTable and many more

Dim dt As New DataTable
Dim da As New SqlDataAdapter("SELECT * FROM [HMS].[dbo].[DoctorRegister]", Connection)
dt.Table("DoctorRegister").clear()
da.Fill(dt, "DoctorRegister")
BindingSource1.DataSource = dt.table("DoctorRegister")
dtpBreakFrom.databind.add("text", BindingSource1, "BreakFrom", False)

Tried with something else....
thank u...

poojavb 29 Junior Poster

Hello Friends,

I need to create a report for my project

I am using Miscrosoft Visual Studio 2010 and the SAP crystal Report

I am not able to set up the connection

The SQL server that I am using is not coming in the drop down of the server part in crystal report

and it is a windows authentication so no password....

when I am filling all the details the drop down is not getting loaded with the database name....

Can anyone help me with the connection....

Thanks....

poojavb 29 Junior Poster

Thats why you mustn't create a new form, just use the form.hide/show methods.

Thank u...it solved my problem.....

poojavb 29 Junior Poster

This code has helped me a lot...but only one problem....

I want the output in a 24 hr format
and this way

08:00
08:30
.
.
.
.
.
.
12:30
13:00
13:30

How can I proceed with this???

I got the answer....

Try
            cboDays.Items.Clear()
            Dim starttime As DateTime = FormatDateTime("00:00")
            Dim endtime As DateTime = FormatDateTime("00:00")
            Dim duration As New TimeSpan
            endtime = TextBox2.Text
            starttime = TextBox1.Text
            duration = TimeValue(TextBox2.Text) - TimeValue(TextBox1.Text)
            Debug.Print("endtime: " + endtime)
            Debug.Print("starttime: " + starttime)
            Debug.Print("duration: " + duration.ToString)
            Dim Dur As Integer = duration.Hours
            Dim Dura As Integer = Integer.Parse(cboTime.Text)
            Do Until starttime >= endtime
                cboDays.Items.Add(FormatDateTime(starttime.TimeOfDay.ToString, DateFormat.ShortTime))
                starttime = starttime.AddMinutes(Dura)
            Loop

        Catch ex As Exception
            Throw ex
        End Try

Thanks to both of u...A tons thanks....

poojavb 29 Junior Poster

See if this helps u...

Try
            Dim starttime As New DateTime
            Dim endtime As New DateTime
            Dim duration As New TimeSpan
            endtime = DateTimePicker2.Text
            starttime = DateTimePicker1.Text
            duration = TimeValue(DateTimePicker2.Text) - TimeValue(DateTimePicker1.Text)
            Dim Dur As Integer = duration.Hours
            Dur = (Dur * 60) / 30

            For i As Integer = 0 To Dur - 1

                cmbTime.Items.Add(starttime.ToString)
                starttime = starttime.AddMinutes(30)
            Next

        Catch ex As Exception

        End Try

This code has helped me a lot...but only one problem....

I want the output in a 24 hr format
and this way

08:00
08:30
.
.
.
.
.
.
12:30
13:00
13:30

How can I proceed with this???

poojavb 29 Junior Poster

Hello All,

I have 3 combo boxes on my form

1. Doctor Start Time
2. Doctor End Time
3. Doctor Appointment Duration

I want a 4th combo Box that will Start from Doctor's Start Time upto Doctor's End Time with the interval of Appointment Duration

eg. Suppose the Start time is 08:00 and End Time 10:00 with 24 hr clock
the appointment duration is 30 mins

then the 4th comboBox should Display
08:00
08:30
09:00
09:30

Can anyone help me in this

I have done this coding on the basis of Appointment Duration

Dim da As DateTime = FormatDateTime("00:00")
        cboAppTime.Items.Clear()
        If txtDuration.Text = "15" Then
            For xa As Integer = 0 To 95
                cboAppTime.Items.Add(FormatDateTime(da.TimeOfDay.ToString, DateFormat.ShortTime))
                da = da.AddMinutes(15)
            Next
        ElseIf txtDuration.Text = "30" Then
            For xa As Integer = 0 To 47
                cboAppTime.Items.Add(FormatDateTime(da.TimeOfDay.ToString, DateFormat.ShortTime))
                da = da.AddMinutes(30)
            Next
        ElseIf txtDuration.Text = "45" Then
            For xa As Integer = 0 To 31
                cboAppTime.Items.Add(FormatDateTime(da.TimeOfDay.ToString, DateFormat.ShortTime))
                da = da.AddMinutes(45)
            Next
        ElseIf txtDuration.Text = "60" Then
            For xa As Integer = 0 To 23
                cboAppTime.Items.Add(FormatDateTime(da.TimeOfDay.ToString, DateFormat.ShortTime))
                da = da.AddMinutes(60)
            Next
        End If

The above coding shows time from 00:00 to 23:00

Need to proceed further with ur help.

poojavb 29 Junior Poster

Hello Friends,

I need to retrive a part of the value present in combobox.

Suppose the ComboBox stores the Time values in it.
eg.
00:00
00:30
01:00
01:30

Then how can I retrive only the hours value or the first two values separately from the Combo Box.

Is there any function like Substring to break the values....

Please help me....

Thanks

I got the answer

poojavb 29 Junior Poster

Hello Friends,

I need to retrive a part of the value present in combobox.

Suppose the ComboBox stores the Time values in it.
eg.
00:00
00:30
01:00
01:30

Then how can I retrive only the hours value or the first two values separately from the Combo Box.

Is there any function like Substring to break the values....

Please help me....

Thanks

poojavb 29 Junior Poster

hello !
i cant get ur point , u just want to move value of the textbox from one form to another or u want to save it then it will show in the previous form ? please rephrase it

Regards

M.Waqas Aslam

Ok Let me rephrase it

I have 2 forms....
When I click on the button of first form it redirects me to the second form which has a datagrid.
When I select any value from the datagrid and click on a button avaialble in the same form the value that I get from the datgrid shoud be displayed on the first form again

But the issue that I am facing is....
When I click on the button of the second form it open the new first form and the earlier values that were there eneterd manually on the first form goes away....

poojavb 29 Junior Poster

Im trying to put current system time in YYMMDD format but having problem with day function.
is Day() which returned day of month in VB6 not available in VB.Net?
If I want to get the current day of month, how would I do that?

Dim dt As Date
Dim dtString As String

dtString = Year(now()) + Month(now()) + Day(now())

Use the below code so that u can get the system date

Dim d As String = Format(Today, "yy/MM/dd")
TextBox1.Text = d
poojavb 29 Junior Poster

U can use ComboBox.SelectedItem or ComboBox.SelectedValue or ComboBox.Text

Try using this...

poojavb 29 Junior Poster

Hello Friends,

I need help on the below issue

I have two forms
-DoctorAppointment
-DoctorSchedule

the DoctorAppointment form has all the details about the doctor and the patient and one Schedule button which will show the DoctorSchedule form

When I click on any value in the DoctorSchedule form like Monday or any other day and click on save button it opens a new DoctorAppointment form and store the Day value in the text box of the form.

The old DoctorAppointment form stays as it is but the new DoctorAppointment form that appears after DoctorSchedule Save click it removes all the earlier values (doctor and patient Details) that were present on the DoctorAppointment Form.

I want that after the Save click it should not call any new form instead the Day value should come on the old form including the Doctor and Patient Details.

Can anyone help me in this?

poojavb 29 Junior Poster

The code did not work..

Its showing error as dt is not a member of DataTable and many more

Dim dt As New DataTable
Dim da As New SqlDataAdapter("SELECT * FROM [HMS].[dbo].[DoctorRegister]", Connection)
dt.Table("DoctorRegister").clear()
da.Fill(dt, "DoctorRegister")
BindingSource1.DataSource = dt.table("DoctorRegister")
dtpBreakFrom.databind.add("text", BindingSource1, "BreakFrom", False)
poojavb 29 Junior Poster

Hello

U can set the CustomFormat property of the picker to hh:00:00 tt
So that it can take only the hour part and not the minutes and seconds

poojavb 29 Junior Poster

Hello Poojavb !
you can use following code to populate your combobox

dim mycon as new sqlconnection (your connection string)
dim mydataset as new dataset
dim bindingsource1 as new bindingsource
mycon.open()
dim da as new sqldataadapter("select patientname from patient",mycon)
mydataset.table("Patient").clear
da.fill(mydataset,"patient")
bindingsource1.datasource = mydataset.table("patient")
combobox1.datasource = bindingsource
combobox1.displaymember = "PatientName"
bindingsource1.datasource =

hope this will help u :)
Regards
M.waqas Aslam

Thanks to all

I did it this way

Dim conn As New SqlConnection(ConnectionString)
        Dim strSQL As String = "SELECT distinct PatientID,PatientName FROM Pat_Doc_Pro"
        Dim da As New SqlDataAdapter(strSQL, conn)
        Dim ds As New DataSet
        da.Fill(ds, "Pat_Doc_Pro")
        With cboPatientID
            '  .Items.Add("Select")
            .DataSource = ds.Tables("Pat_Doc_Pro")
            .DisplayMember = "PatientName"
            .ValueMember = "PatientID"
            .SelectedIndex = 0
        End With
poojavb 29 Junior Poster
public class form1
'Put textbox and button1 on form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Visible = True
    End Sub
End class


Public Class Form2
'put listbox1,button1 on form 2
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListBox1.Items.Add("TEST")
        ListBox1.Items.Add("TEST1")
        ListBox1.Items.Add("TEST2")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Form1.TextBox1.Text = ListBox1.SelectedItem
        Me.Visible = False
        Form1.Visible = True

    End Sub
End Class

this has helped me a lot....
Thank u so much

but can u tell me that without again opening the form1 how can the value be set

poojavb 29 Junior Poster

Is your database field is datetime or varchar

In MySql the column datatype is time(0)
In vb.net the type is time
But still its showing the conversion error

poojavb 29 Junior Poster

Hello Friends,

I need one urgent help on this topic.

I have a database in mysql.
The column in table is of datatype time(0)

Similarly I have a control datetimepicker in vb.net
I have assigned format property as custom to the control and the CustomFormat property as HH:mm:ss tt so that it can just provide the time.
I dont want the date to be in it.

Issue comes when I try to retrieve the value from database
I get an error as Converion of type 'Timespan' to type 'Date' is not valid

Can anyone help me in this?

Try
   Dim myCommand As SqlCommand
   myCommand = New SqlCommand("select * from [HMS].[dbo].[DoctorSchedule] where DoctorID='" & txtDoctorID.Text & "'", Connection)
   Dim reader As SqlDataReader = myCommand.ExecuteReader
       While reader.Read
           TextBox1.Text = reader("ScheduledID")
           dtpMonST.Value = reader("MonST")
       End While

Catch ex As Exception
   MessageBox.Show("Error Connecting to Database: " & ex.Message)
End Try
poojavb 29 Junior Poster

Hello,

Please tell me how to add a string item to a text box, returned from another form that has a list box?

I have two forms.

on the first form I have a button which calls another form that has a List Box.
When I select the value from the list box and click on the apply button then the value should be passed to the first form that will also have a text box.

The text box should contain the value of list box.

Please help me in this.