Can you show the complete code...
poojavb 29 Junior Poster
Can you show the complete code...
Just an idea to start.....this will deal with ur first condition of spaces
Dim s As String = "This is my Dog"
Dim words As String() = s.Split(" "c)
Array.Reverse(words)
s = String.Join(" "c, words)
U need this code / idea in which programming laguage???
U r not clear enough.....Please mention in detail....
just giving the synopsis of what u can do....
After creating the form and the search text box....
- in ur form tag u can add the methods action and specify the google search...
- else mention the name of ur site....so that the search is performed within ur code
Give it a try...
give same name for the radio button and just change the value....if the names are different it falls in different group
<body>
<input type="radio" name="test" value="a">a<br>
<input type="radio" name="test" value="b">b<br>
<input type="radio" name="test" value="c">c<br>
<input type="radio" name="test" value="d">d</body>
</body>
When I tried ur code...it shows error that few of ur variables are not initialized....Please check the initialization of variables,,,
Since I dont have ur BankAccount class I get the following errors
varaibles cannot be resolved to a variable for the below variables
interestRate
pay
cashNeeded
if u want to set the form size to maximum then change the windows state property of the form to Maximized
Got it solved
'declaring variables
Dim subject As String
Dim body As String
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
'Open Connection
Dim myCommand2 As SqlCommand
myCommand2 = New SqlCommand("SELECT * from HMS.dbo.Product where Inventory <= ReorderLimit", Connection)
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader
body = "The below medicines have reached its reorder level. Please place the required orders " + Environment.NewLine + "Product Details" + Environment.NewLine
If reader2.HasRows Then
While reader2.Read()
body = body + Environment.NewLine + "Product ID: " + reader2("Prodid") + Environment.NewLine + "Product Name: " + reader2("ProdName") & Environment.NewLine
End While
reader2.Close()
subject = "Medicines Exceeding Reorder Level"
body = String.Format("body={0}", Uri.EscapeDataString(body))
System.Diagnostics.Process.Start("mailto:" & "" & "?subject=" & subject & "&" & body)
Else
MsgBox("No medicines")
End If
'Close Connection
End Sub
In case u need to loop even if the user enter correct number take ur if condition one place down....
import javax.swing.JOptionPane; // Needed for JOptionPane
/**
Chapter 3.1 Roman Numerals
*/
public class Chapter3dot1
{
public static void main(String[] args)
{
int num;
String input;
boolean shouldContinue = true;
while(shouldContinue)
{
shouldContinue = false;
input = JOptionPane.showInputDialog("Enter a number between 1 and 10 " +
"and I will convert it to a Roman numeral: ");
num = Integer.parseInt(input);
if (num == 1)
JOptionPane.showMessageDialog(null, "I");
else if (num == 2)
JOptionPane.showMessageDialog(null, "II");
else if (num == 3)
JOptionPane.showMessageDialog(null, "III");
else if (num == 4)
JOptionPane.showMessageDialog(null, "IV");
else if (num == 5)
JOptionPane.showMessageDialog(null, "V");
else if (num == 6)
JOptionPane.showMessageDialog(null, "VI");
else if (num == 7)
JOptionPane.showMessageDialog(null, "VII");
else if (num == 8)
JOptionPane.showMessageDialog(null, "VIII");
else if (num == 9)
JOptionPane.showMessageDialog(null, "IX");
else if (num == 10)
JOptionPane.showMessageDialog(null, "X");
else { //error message
JOptionPane.showMessageDialog(null, "Not good at following instructions?" +
"\nI said enter a number between 1 and 10!");
}
if( JOptionPane.showConfirmDialog(null,
"Do you want to try again?",
"Try again?", JOptionPane.YES_NO_OPTION)
== JOptionPane.YES_OPTION )
shouldContinue = true;
};
System.exit(0);
}
}
Ok let me tell u what I have done....
I have a Datagridview in which I have added 6 columns manually through property window,,,
On button click I have the following code....but before that declare two variables
Dim rowvalue As String
Dim cellvalue(20) As String
then in button click write
Dim streamReader As IO.StreamReader = New IO.StreamReader("D:\abc.csv")
'Reading CSV file content
While streamReader.Peek() <> -1
rowValue = streamReader.ReadLine()
cellvalue = rowvalue.Split(","c) 'check what is ur separator
DataGridView1.Rows.Add(cellValue)
End While
Hope this is what u needed
If I use a <br> tag then the output is as
The below medicines have reached its reorder level. Please place the required orders <br>Product ID: PRD4Product Name: Metacin<br>Product ID: PRD5Product Name: Saframycin<br>Product ID: PRD6Product Name: Glycodin
If I use vbCrLf the output is
The below medicines have reached its reorder level. Please place the required ordersProduct ID: PRD4Product Name: MetacinProduct ID: PRD5Product Name: SaframycinProduct ID: PRD6Product Name: Glycodin
I tried using so many tags but still its not working....
actually debug.print shows the correct output....but in the email the newline is not getting applied....this output is when I apply vbCrLf or Environment.Newline
The below medicines have reached its reorder level. Please place the required orders
Product ID: PRD4
Product Name: Metacin
Product ID: PRD5
Product Name: Saframycin
Product ID: PRD6
Product Name: Glycodin
Mark thread as solved if its done....
In short words.....
import static java.lang.System; - It means u are just trying to import the namespace System
import static java.lang.System.*; - It means u are trying to import all the namespaces that comes under System....no need to import the namespaces that comes under System again....
One more help...
Can anyone tell me how do I insert newline in the email body part...
I tried everything like Environment.Newline, vbcrlf, and even the html tags :) and "/n" and event other charatcers but failed
check my below code
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
Dim subject As String
Dim body As String
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
Dim Openconnection As String
Openconnection = Open_DB_Connection("form7 - Button1 click")
Dim prodname As String
Dim prodid As String
Dim address As String
address = ""
Dim myCommand2 As SqlCommand
myCommand2 = New SqlCommand("SELECT Prodid,ProdName from Product where Inventory <= ReorderLimit", Connection)
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader
body = "The below medicines have reached its reorder level. Please place the required orders "
If reader2.HasRows Then
While reader2.Read()
prodname = reader2("ProdName")
Debug.Print("Prod name: " + prodname)
prodid = reader2("Prodid")
body = body + " " + "Product ID: " + prodid + " " + "Product Name: " + prodname & " "
End While
Debug.Print("body: " + body)
reader2.Close()
mail.Body = body
subject = "Medicines Exceeding Reorder Level"
System.Diagnostics.Process.Start("mailto:" & address & "?subject=" & subject & "&body=" & mail.Body)
Else
MsgBox("No medicines")
End If
Dim Closeconnection As String
Closeconnection = Close_DB_Connection("form7 - Button2 click")
End Sub
I want the email body output as
The below medicines have reached its reorder level. Please place the required orders
Product ID: PRD4
Product Name: Metacin
Product ID: PRD5
Do post your code after u solve it successfully so that it is helpful to others....
Is this what u r looking for???
Imports System.Data.SqlClient
Public Class Form8
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim Openconnection As String
Openconnection = Open_DB_Connection("form7 - Button1 click")
Dim da As New SqlDataAdapter("SELECT Distinct Doctorid FROM DoctorRegister", Connection)
Dim dt As New DataTable
da.Fill(dt)
With ComboBox1
' .Items.Add("Select")
.DataSource = dt
.DisplayMember = "Doctorid"
.ValueMember = "Doctorid"
.SelectedIndex = 0
End With
Debug.Print(ComboBox1.SelectedValue.ToString)
Dim Closeconnection As String
Closeconnection = Close_DB_Connection("form7 - Button2 click")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim Openconnection As String
Openconnection = Open_DB_Connection("form7 - Button1 click")
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT * FROM [DoctorRegister] where DoctorID='" + ComboBox1.Text + "'", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
While reader.Read
TextBox1.Text = reader("FirstName") + Environment.NewLine + reader("LastName")
'insert number of data u need in text box with Environment.NewLine
End While
reader.Close()
Dim Closeconnection As String
Closeconnection = Close_DB_Connection("form7 - Button2 click")
End Sub
End Class
Instead of opening ur database in form load event try to open it in ur click events....
Hey I got the answer....I am so happy after so many days of trying today I got the answer....
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
Dim subject As String
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
Dim Openconnection As String
Openconnection = Open_DB_Connection("form7 - Button1 click")
Dim count As Integer
Dim prodname As String
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT count(*) as count1 FROM [Product] where Inventory < ReorderLimit", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
While reader.Read
count = reader("count1")
End While
reader.Close()
If count > 0 Then
Dim myCommand2 As SqlCommand
myCommand2 = New SqlCommand("SELECT ProdName from Product where Inventory < ReorderLimit", Connection)
Dim reader2 As SqlDataReader = myCommand2.ExecuteReader
subject = "The below medicines have reached its reorder level. Please place the required orders "
While reader2.Read()
prodname = reader2("ProdName")
subject = subject & Environment.NewLine & prodname
End While
reader2.Close()
SmtpServer.Credentials = New Net.NetworkCredential("abc.def.com", "abc")
SmtpServer.Port = 29
SmtpServer.Host = "mail.abc.com"
mail = New MailMessage()
mail.From = New MailAddress("abc.def.com")
mail.To.Add("abc.def.com")
mail.Subject = "Medicines Exceeding Reorder Level"
mail.Body = subject
SmtpServer.Send(mail)
MsgBox("Mail sent sucessfully")
Else
MsgBox("No medicines have reached its reorder value")
End If
Dim Closeconnection As String
Closeconnection = Close_DB_Connection("form7 - Button2 click")
End Sub
Could not edit my previous post....
@Jim - check my code below it gives different email for different product
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
Dim Openconnection As String
Openconnection = Open_DB_Connection("form7 - Button1 click")
Dim count As Integer
Dim productname As String
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT count(*) as count1 FROM [Product] where Inventory < ReorderLimit", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
While reader.Read
count = reader("count1")
End While
reader.Close()
If count > 0 Then
' MsgBox("Greater than 0")
Dim ds As New DataSet
Dim sqlstring As String
sqlstring = "select ProdName from Product where Inventory < ReorderLimit"
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlstring, Connection)
da.Fill(ds)
Dim rows(ds.Tables(0).Rows.Count) As String
' Loop through all rows in Categories table
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
rows(i) = ds.Tables(0).Rows(i).Item(0).ToString
Debug.Print(rows(i))
'Next
'For i As Integer = 1 To count
productname = rows(i)
Debug.Print("Prodname:" + productname)
Dim subject As String = "Please send these medicines: " + productname
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New Net.NetworkCredential("abc.def.com", "abc123def")
SmtpServer.Port = 29
SmtpServer.Host = "mail.abc.com"
mail = New MailMessage()
mail.From = New MailAddress("abc.def.com")
mail.To.Add("abc.def.com")
mail.Subject = "Lack of List of medicines"
For j As Integer = 1 To count
subject = subject & Environment.NewLine & productname(j) & Environment.NewLine
Next
mail.Body = subject
SmtpServer.Send(mail)
MsgBox("mail sent sucessfully for reorder")
Next
Else
MsgBox("No")
End If
Dim Closeconnection As String
Closeconnection = Close_DB_Connection("form7 - Button2 click") …
@Jim - can u tell me how to do this part
for each record in recordset
add inventory item to email message
next
Check my code below....just a temp code....
'Open Connection
Dim count As Integer
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT count(*) as count1 FROM [Product] where Inventory < ReorderLimit", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
While reader.Read
count = reader("count1")
End While
If count > 0 Then
MsgBox("Greater than 0")
Else
MsgBox("No")
End If
'Close Connection
Hello Friends....I got it working....
Have a look at the code....
'Open Connection
'Retrive records from database
Dim myCommand1 As New SqlCommand
With myCommand1
.CommandText = "SELECT * FROM TableName"
.CommandType = CommandType.Text
.Connection = Connection
End With
'Fill the datagridview with the records
Dim dt As New DataTable
dt.Load(myCommand1.ExecuteReader)
If dt.Columns.Count > 0 Then
With dgvDetails
.DataSource = dt
End With
End If
'Set readonly values to particular cell and set background color
For RCnt As Integer = 0 To dgvDetails.Rows.Count - 1
If dgvDetails.Rows(RCnt).Cells("Status").Value = "InProgress" Then
dgvDetails.Rows(RCnt).ReadOnly = False
dgvDetails.Rows(RCnt).DefaultCellStyle.BackColor = Color.YellowGreen
ElseIf dgvDetails.Rows(RCnt).Cells("Status").Value = "Received" Then
dgvDetails.Rows(RCnt).ReadOnly = True
dgvDetails.Rows(RCnt).DefaultCellStyle.BackColor = Color.Pink
End If
Next
'Close connection
Actually I know how to set it as readonly....what I want is according to the string in the column of datagridview as order or received the row shud be enabled and disabled....
Actually I dont know much about arrays....so I want how to send all the product names in one email whosever have reached the reorder level....
Can anyone tell me thru coding....or correct what I have done in my coding....
@Jim - I understood what u have said...but I want the product names....
Check ur database connections....while retrieving the values from database.....
Instead of using parameters try it with the text boxes it self....
Dim cmd As New SqlCommand("insert into dbo.RMA values ('"+TxtRMA.Text+"','"+TxtVendor.Text+"','"+TxtDevice.Text+"','"+TxtSN.Text+"','"+TxtModel.Text+"','"+TxtProblem.Text+"','"+TxtDate.Text+"')")
Can anyone help me in this????
Hello Friends,
One help needed....
I have a product database....in which I have productid,prodname,inventoryvalue,reordervalue
I have to design a email system that as soon as the product reaches the reorder level it shud generate an email....
but the condition is there will be many products in the database....and on one button click it should send only one email but with all product names those reached the reorder level....
I tried the below thing but completely a waste...
Please do help me....
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
'Open Connection
Dim reorder As Integer
Dim inventory As Integer
Dim prodname As String
Dim prodcount As Integer
'get the total number of product in database
Try
Dim myCommand1 As SqlCommand
myCommand1 = New SqlCommand("SELECT count(*) as 'Total' FROM [Product]", Connection)
Dim reader1 As SqlDataReader = myCommand1.ExecuteReader
While reader1.Read()
prodcount = reader1("Total")
End While
Debug.Print(prodcount.ToString)
reader1.Close()
'get the values of product names in a array
Dim ds As New DataSet
Dim sqlstring As String
sqlstring = "select ProdName from Product"
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlstring, Connection)
da.Fill(ds, "Product")
Dim temp As Integer = ds.Tables("Product").Rows.Count
Dim arr1() As String
For i = 0 To temp - 1
arr1(i) = ds.Tables("Product").Rows(i).Item("ProdName")
Next
For i As Integer = 1 To prodcount
prodname = arr1(i)
Debug.Print("in for: " + i.ToString)
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT * FROM [Product] where ProdName='" + prodname + "'", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
reader.Read()
prodname = reader("ProdName")
reorder …
what error are u getting???
things u can check
1. check the datatype ...it shud be number related datatype
2. check the values u r passing to the date column....
3. the value for date shud be in the same format as it is there in database....
it worked for me but I manuallly passed values....
SELECT SUM ([Total]) FROM Tablename where [dtpDate] between '2012-05-22' and '2012-05-22'
total - int datatype
dtpDate - date datatype....
I tried this in mssql....what database r u using??? check that too...
You will need a dot net professional version and after installing that u also need to change the framework from client to framework 4
I have used this code in all my application for form_closing event.....
It works out very well for me....
I dont know y its not working for u....
that I understood...what I am asking is for one combox value will the text box have one value or many values???
did u check with the code I have posted??? give it a try....
check ur syntax for delete
"delete from STAFF where Staff ID like '" & txtKeyword.Text & "%" + "'"
for ur update query try doing this...
"update tablename set Student_Name='"+txtName.Text+"' where Student_HP_No='"+mtxPhoneNo.Text+"' and Student_Email='"+txtEmail.Text+"'"
I am not so very sure but check if we can add spaces between column names....please do confirm....
One more thing is u can use Debug.Print("your commandtext")
- to find our what the query is....
Does your combo box selection result return only a single value???
Check what I have done...hope it helps u....set textbox AutoCompleteMode property to SuggestAppend
Imports System.Data.SqlClient
Public Class Form6
Private Sub Form6_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Open connection
Dim strSQL As String = "SELECT Distinct ID,FirstName FROM Tablename"
Dim da As New SqlDataAdapter(strSQL, Connection)
Dim ds As New DataSet
da.Fill(ds, "Tablename")
With ComboBox1
.DataSource = ds.Tables("Tablename")
.DisplayMember = "FirstName"
.ValueMember = "ID"
.SelectedIndex = 0
End With
'Close connection
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
'Open connection
Try
Dim myCommand As SqlCommand
myCommand = New SqlCommand("SELECT LastName FROM Tablename where FirstName='" + ComboBox1.Text + "'", Connection)
Dim reader As SqlDataReader = myCommand.ExecuteReader
While reader.Read()
TextBox1.Text = reader("LastName")
End While
reader.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Close connection
End Sub
End Class
Hope it helps u....
Hey thanks Jim....I could delete the folder.....
Can u tell me where does this Take ownership comes under....coz I could not find anything when I did right click
I am using Windows 7
call this code on ur button click to display ur records in datagridview
'open connection
Try
Dim myCommand As New OleDbCommand
With myCommand
.CommandText = "SELECT * FROM tablename"
.CommandType = CommandType.Text
.Connection = Connection
End With
Dim dt As New DataTable
dt.Load(myCommand.ExecuteReader)
With DatagridView1
.AutoGenerateColumns = True
.DataSource = dt
End With
Catch ex As Exception
MsgBox("Error in select query: " + ex.Message)
End Try
'close connection
This folder got created in my E:\
No I did not install any service pack CD
Created On: Wednesday, July 06, 2011, 4:03:36 PM....
Actually I am not able to delete the folder
When I try to delete it....it tells that U need permission form So and So to perform anything on this folder...
but I have the admin rights....and that so and so is also some weird...check my attachment
even I dont know how did this folder get created in my system
Is it a virus??? as I tried to scan it...it showed no threats...and also one more thing the folder cannot be opened....
Union shud work and give the same alias name for all...
SELECT DISTINCT FirstName as Name From HMS.dbo.DoctorRegister
UNION
SELECT DISTINCT LastName AS Name FROM HMS.dbo.DoctorRegister
UNION
SELECT DISTINCT FName As Name FROM HMS.dbo.InpatientDetails
hope this is what u need...
This is not a vb.net question....u shud try in web development section
Ohh....I have posted in ur other duplicate post....
pasting it again........
To just populate ur datagrid with the values from database u can use the below code
'Open connection
Dim myCommand1 As New SqlCommand
With myCommand1
.CommandText = "SELECT * from Table"
.CommandType = CommandType.Text
.Connection = Connection
End With
Dim dt As New DataTable
dt.Load(myCommand1.ExecuteReader)
If dt.Columns.Count > 0 Then
With DataGridView1
.DataSource = dt
End With
End If
'Close connection
Hope it helps.
Great.....thank u very much Muhammad Waqas Aslam......it helped me a lot.....
Folder name such as da12e5154f6b530007fd9e got automtically created in my system...
Can anyone please tell me why such folders get created and how can I delete it...
ur query tells that the select query shud display the results according to job number...so what ever will be present in ur text box only that part will be shown....
modify ur select query to show all the records...remove the jobnumber criteria if u want all the records....
"select estimate.[JOB NUMBER] AS JobNo, REPLACE(CONVERT(VARCHAR, CONVERT(MONEY,estimate.[Qty1]),1),'.00','') AS JobQty, estimate.[FINAL DELIVERY] AS DropDate from estimate where estimate.[JOB NUMBER] = '" & jobnumber & "'"
This is VB.net section.... Servlet comes in Java....
This is not the correct section to post the code dear.....
Check if this helps u in any way....
Below code is written in Main form closing event
Private Sub frmMain_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim dr As Object
If e.CloseReason = CloseReason.UserClosing Then
dr = MsgBox("Are you sure to exit the application?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, "Hospital Management System")
If dr = vbYes Then
Me.Dispose() 'close the main form
frmLogin.Show() 'shows the login form when main form closes
e.Cancel = False
Else
e.Cancel = True
End If
Else
e.Cancel = True
End If
End Sub
What does ur MaxVal stores??? no attachment displayed
ur welcome....if it helped u dont forget to mark the thread as solved...
Me.Visible = False
try this :)
" The optimum value is 13 at House 1 and House 2"
In this is 13 ur row number??
As I understood u want to display the row number of the item which will be clicked
Dim MaxVal As Integer
For a = 0 To DataGridView1.RowCount - 1
MaxVal = DataGridView1.CurrentCell.RowIndex + 1
Next
MsgBox("The Optimum Value is " & MaxVal, 1, "Optimum Choice")
Please correct me if u need something else....