|
I realise this is an old post but it might help someone else out.
I needed to do a similar thing but I didn't want to concatinate fields in the sql used to fill the datatable as it was contained in an existing stored procedure. So I filled the datatable with the records I wanted then basically added another column in the datatable which was my concatinated display value. I then used this new column as the DisplayMember.
assuming we have a datatable which is populated with "AccountCode" and corresponding "AccountName"
eg "ABC" , "Freds workshop"
"XYZ" , "Bills Lighting"
'Add a new calculated column to the datatable
Dim DataCol As DataColumn = New DataColumn("Display")
DataCol.DataType = System.Type.GetType("System.String")
DataCol.Expression = "AccountCode + (' - ') + AccountName"
dt.Columns.Add(DataCol)
'Now setup the combobox
cmbAvailableCompanies.DataSource = dt
cmbAvailableCompanies.DisplayMember = "Display"
cmbAvailableCompanies.ValueMember = "AccountsCode"
It will now display "ABC - Freds Workshop" and "XYZ - Bills Lighting" in the combobox.
The only issue I have found is if I turn sorting of the combobox on the SelectedValue of the combobox gets out of sync with the Displayed value. I haven't worked this out yet but for the time being I can live with it.
|
|
|
|
|
Hi!
How do I allow the user to reload the main form of the application? In essence, I want a button that closes the whole program and opens it again, starting from scratch.
thanks
|
|
|
|
|
Write a method that sets the initial state of your controls and variables, call it in your form load ( so it always works the same ) and call it again from a button event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hii Friends
I have a form in my software in which if user is connected to internet can send an querry to my id, myid@gmail.com. Two textboxes one for sender email id will be written and another for subject, And the main querry in the multiple lines text box. i have a smptp and pop3 account with gmail.com as smtp.gail.com and pop.gmail.com . How can i do this which namespace i have to import for tat and the code is required.
I have been tryin on this
Please share if u have N E idea.
Thanks
Nikhil Bandekar
Mumbai,
India
|
|
|
|
|
This[^] works for me.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Dear all
i am trying to find out a way to store any mails recieved in MS outlook into a MSSQL database located remotely
can anyone help with this
the database has the following fields From_ID <varchar(40)> To_ID <varchar(30)> Subject <varchar(50)> Message <varchar(1600)> Date <datetime>
Its pretty urgent
Please Help
Gaurav
|
|
|
|
|
i am using the following code as connection string
for importing Excel file to dataset in Vb.ne
MDAC and Excel all r installed
but i got the following error "Could not find installed ISAM"
this work is urget for tomorow.can u help me
is this wrong.pls give the correct code.
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source='" & strfilename & "'; " & _
"Extended Properties=Excel 8.0;HDE=NO;IMEX=1")
|
|
|
|
|
|
hi,
Thanks a lot.........
last 3, 4 days i was so busy.thts why i cuould not sent mail to u.sorry for the delay
the link u have given me is verymuch helpful to me.
once again thanks.
|
|
|
|
|
Hi Viji,
No Problem, you are always wecome.....
Regards
sarathy
Know is Drop, Unknown is Ocean
|
|
|
|
|
Hello Everyone
I'm using VB. Net, can you tell me how to display records in a datagrid in a Date range. I have 2 DataAdapters, the other one has parameters "Date" and one DateTimePicker.
|
|
|
|
|
Dear Friends,
i have a problem, when i call the printtoprinter function i recieve an error
my code is
Dim Report As New rptCaisseAll
Dim Us, Fc, qty, prix, total, totcomis, bacv, bacl, soldefc, soldeus As String
RefCaisse.GetRcords("*", "CaisseDate in (select Max(CaisseDate) from Ref_PDCaisse where CaisseDate< convert(datetime,'" & Me.txtDate.Text & "',103))")
RefCaisse.FillBoxControlles("", Us, Fc)
Caisse.GetRecords("Exchrate,AmountUS,AmountFc,s.Notes,s.DbCr,AccName,s.AccNo", "EntryDate=convert(datetime,''" & Me.txtDate.Text & "'',103) And s.AccNo<>40101", "s.DbCr")
Caisse.SelectspecialMethod()
livraison.GetRecords("Sum(BacLiv) AS BacLiv", "LivDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
livraison.SelectMethod()
'comisTot.GetRecords("TotalComis", "ComisDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
'comisTot.SelectMethod()
fiche.GetRecords("Sum(Commission) as Commission", "OpDate<=convert(datetime,''" & Me.txtDate.Text & "'',103) And Operation=''Commande''")
totcomis = fiche.SumMontant()
fiche.GetRecords("Sum(Commission) as Commission", "OpDate<=convert(datetime,''" & Me.txtDate.Text & "'',103) And Operation=''Commission''")
totcomis = totcomis - fiche.SumMontant()
If Me.txtDate.Text = Now Then
stock.GetRecords("tblStock.OrdCode as OrdCode,tblStock.ArtCode as ArtCode,InQty,OutQty,FinalQty,tblProDetails.Qty As Qty", "tblProDetails.OrdCode=tblStock.OrdCode AND ProdDate=convert(datetime,''" & Me.txtDate.Text & "'',103) And (tblStock.FinalQty<>0 OR tblProDetails.Qty<>0) AND tblStock.DepCode=''KIC''", "ArtCode", 1)
stock.SelectspecialMethod()
Else
stock.Stock(CDate(Me.txtDate.Text))
stock.ClearSet()
End If
Report.Database.Tables.Item("ReCaisse;1").SetDataSource(Caisse.CaisseSet.Tables(0))
Report.Database.Tables.Item("RptSumLiv;1").SetDataSource(livraison.dsTable.Tables(0))
'Report.Database.Tables.Item("RptTotalComis;1").SetDataSource(comisTot.dsTable.Tables(0))
Report.Database.Tables.Item("RptStockProd;1").SetDataSource(stock.dsTable.Tables(0))
'commande.GetRecords("Sum(Qty) AS Qty", "ComDate<=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-1).ToString & "'',103)")
'commande.SelectMethod()
'Report.Database.Tables.Item("RptSumComYesterday;1").SetDataSource(commande.dsTable.Tables(0))
'livraison.GetRecords("Sum(BacLiv) AS BacLiv", "LivDate<=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-1).ToString & "'',103)")
'livraison.SelectMethod()
'Report.Database.Tables.Item("RptSumLivYesterday;1").SetDataSource(livraison.dsTable.Tables(0))
fiche.GetRecords("Sum(Qty) AS Qty", "OpDate<=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-1).ToString & "'',103) and Operation=''Commande''")
fiche.SelectMethod()
Report.Database.Tables.Item("RptSumComYesterday;1").SetDataSource(fiche.dsTable.Tables(0))
fiche.GetRecords("Sum(Qty) AS BacLiv", "OpDate<=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-1).ToString & "'',103) and Operation=''Livraison''")
fiche.SelectMethod()
Report.Database.Tables.Item("RptSumLivYesterday;1").SetDataSource(fiche.dsTable.Tables(0))
production.GetRecords("SoldeProd", "ProdDate=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-1).ToString & "'',103)")
production.SelectMethod()
Report.Database.Tables.Item("RptProductionSolde;1").SetDataSource(production.dsTable.Tables(0))
production.GetRecords("Qty,SoldeProd", "ProdDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
production.SelectMethod()
Report.Database.Tables.Item("RptProduction;1").SetDataSource(production.dsTable.Tables(0))
production.GetRecords("Sum(tblProDetails.Qty) AS Qty", "(ArtCode=''FRMDT'' Or ArtCode=''MIDMA'') AND ProdDate=convert(datetime,''" & Me.txtDate.Text & "'',103)", , 1)
production.SelectMethod()
Report.Database.Tables.Item("RptProDetails;1").SetDataSource(production.dsTable.Tables(0))
commande.GetRecords("Sum(Qty) AS Qty", "ComDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
commande.SelectMethod()
Report.Database.Tables.Item("RptSumCom;1").SetDataSource(commande.dsTable.Tables(0))
livraison.GetRecords("Sum(BacLiv) AS BacLiv", "LivDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
livraison.SelectMethod()
Report.Database.Tables.Item("RptSumLiv;1").SetDataSource(livraison.dsTable.Tables(0))
'client.GetRecords("Sum(BacLiv) as BacLiv,Sum(BacVide) AS BacVide")
'client.SelectMethod()
'Report.Database.Tables.Item("RptSumClient;1").SetDataSource(client.dsTable.Tables(0))
fiche.GetRecords("Sum(Qty) as Qty", "OpDate<=convert(datetime,''" & Me.txtDate.Text & "'',103) And Operation=''Commande''")
bacl = fiche.SumQty()
fiche.GetRecords("Sum(Qty) as Qty", "OpDate<=convert(datetime,''" & Me.txtDate.Text & "'',103) And Operation=''Livraison''")
bacl = bacl - fiche.SumQty()
fiche.GetRecords("(Sum(qty)-Sum(bacvide)) as Qty", "OpDate<=convert(datetime,''" & Me.txtDate.Text & "'',103) And Operation=''Livraison''")
bacv = fiche.SumQty
stock.GetRecords("Sum(FinalQty) As FinalQty", "ArtCode=''FRMDT'' AND DepCode=''KIC''")
stock.SelectMethod()
Report.Database.Tables.Item("RptStock;1").SetDataSource(stock.dsTable.Tables(0))
Acc.GetRecords("AccNo as x,AccNo,AccName,BalUS,BalFC,DbCr", "AccNo=46030")
Acc.SelectMethod()
Report.Database.Tables.Item("ReAccount;1").SetDataSource(Acc.SoAccSet.Tables(0))
commande.GetRecords("Sum(Qty) as Qty,Avg(Prix)as Prix,Sum(Total) as Total,Max(ComID)as ComID,Max(ClCode)as ClCode,Max(Notes)as Notes,Max(ComDate)as ComDate", "ComDate=convert(datetime,''" & Me.txtDate.Text & "'',103)")
commande.FillBoxControls(, , , , qty, prix, total, )
Comis = Double.Parse(total) - CInt(qty) * Double.Parse(prix)
Dim i As Integer = 1
Dim Bag(8) As String
Dim Sac(8) As String
Dim TotSac, count As String
Dim pcode, pdate, spro, des, a As String
pcode = ""
pdate = ""
spro = ""
des = ""
a = ""
TotSac = 0
count = 0
For i = 1 To 7
Bag(i) = Nothing
Sac(i) = Nothing
production.GetRecords("*", "ProdDate=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-i).ToString & "'',103)")
production.FilBoxCotrolles(pcode, Bag(i), pdate, spro, des, a)
production.GetRecords("Sum(tblProDetails.Qty) as Sac", "ProdDate=convert(datetime,''" & CDate(Me.txtDate.Text).AddDays(-i).ToString & "'',103) AND (ArtCode=''FRMDT'' OR ArtCode=''MIDMA'')", , 1)
production.FillSum(Sac(i))
If Bag(i) = Nothing Then
Bag(i) = 0
End If
If Sac(i) = Nothing Then
Sac(i) = 0
End If
If Sac(i) <> 0 Then
count += 1
End If
TotSac = Convert.ToInt32(TotSac) + Convert.ToInt32(Sac(i))
'production.FilBoxCotrolles(pcode, a, pdate, spro, des, Sac(i))
Next
soldefc = Nothing
soldeus = Nothing
Caisse.GetRecords("*", "EntryDate=convert(datetime,''" & Me.txtDate.Text & "'',103) And AccNo=40101")
Caisse.FillBoxControls(, , , , soldefc, soldeus)
If soldefc = Nothing Then
soldefc = Me.txtCFc.Text
soldeus = Me.txtCUs.Text
End If
Report.DataDefinition.FormulaFields.Item("Date").Text = "totext('" & Me.txtDate.Text & "')"
Report.SetParameterValue("SoldeFC", soldefc, "ReCaisse.rpt")
Report.SetParameterValue("SoldeUS", soldeus, "ReCaisse.rpt")
Report.SetParameterValue("Us", Us, "ReCaisse.rpt")
Report.SetParameterValue("Fc", Fc, "ReCaisse.rpt")
Report.SetParameterValue("Total", Me.Vend, "rptTotal.rpt")
Report.SetParameterValue("Commission", Me.Comis, "rptTotal.rpt")
Report.SetParameterValue("TotComis", totcomis, "rptTotal.rpt")
Report.SetParameterValue("BacLiv", bacl, "rptBag.rpt")
Report.SetParameterValue("BacVide", bacv, "rptBag.rpt")
'Report.SetParameterValue("Qty", Me.Comis, "rptTotal.rpt")
For i = 1 To 7
Report.SetParameterValue("Date" & i, CDate(Me.txtDate.Text).AddDays(-i).ToString, "RptProdSem.rpt")
Report.SetParameterValue("Bag" & i, Bag(i), "rptProdSem.rpt")
Report.SetParameterValue("Sac" & i, Sac(i), "rptProdSem.rpt")
Next
Report.SetParameterValue("TotSac", TotSac, "rptProdSem.rpt")
Report.SetParameterValue("Count", count, "rptProdSem.rpt")
Report.PrintToPrinter(1, True, 1, 9)
in the laste instruction i recieved the folowing error
An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.LogOnException' occurred in crystaldecisions.crystalreports.engine.dll
Additional information: Logon failed
So any body can help me
|
|
|
|
|
What is wrong with my statement?
Dim mySelectQuery As String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'"
Rdate is a value from the database.
I get this error : Cast from string "SELECT * FROM table where recv" to type 'Long' is not valid.
Thank you
|
|
|
|
|
All 3 expressions for between must be the same datatype. If Rdate is from Type Date you must convert FromData.value and ToDate.value to a Date. This conversion depends on the database system. Look there for more information. If you use SQLServer see in Transact-SQL-Help for command 'CAST', 'CONVERT','BETWEEN' and 'DATETIME'.
Regards
Stephan
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href=http:
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
Rigard wrote: String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'"
Try this (Assuming RDate is of DateTime type):
"SELECT * FROM table where Rdate between #" & FromDate.Value & "#" And "#" & ToDate.Value & "#"
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Rigard wrote: What is wrong with my statement?
You inject values into the SQL, which is a security risk and causes other problems.
Use parameterised queries instead of injecting values.
|
|
|
|
|
HI..
I would like to know how to design an annotation tool for a web-based courseware using vb.net. I have to open a page in vb and then do annotation to it such as highlighting text, adding text, etc..
zarine
|
|
|
|
|
Hi all,
does anyone know about how to build a Email sending function in a website? cause we are trying to enable customers to send news and some images of our products to their friends. Our news is storded in an XML file.when we display the News we will use the XMLReader to read the whole content in the XML file and save it with some reasonable html codes into a string variable. And then display the sting variable in a label. When we run it, the formated content will be display.
And we would like to send the same News page or at least some formated XML content file to the customers' friends.
But the email we managed to send can only send string, no pictures allowed. and when we send Label1.text, it send all the stings instead of the formated page.
Can anyone help!!!
Jackie Ding
|
|
|
|
|
Hello Jackie,
see code below. It's easy to extend it to send attachments. Look at MSDN for the both classes.
Private Sub SendMail(ByVal Sender As String, ByVal Subject As String, ByVal Body As String)
Dim oSmtp As System.Web.Mail.SmtpMail
Dim oMailMsg As New System.Web.Mail.MailMessage
oMailMsg.From = Sender
oMailMsg.To = "recv1@account.com;recv2@account.com"
oMailMsg.Body = Body
oMailMsg.BodyFormat = System.Web.Mail.MailFormat.Html
oMailMsg.Subject = Subject
oSmtp.SmtpServer = ConfigurationSettings.AppSettings("MailServer")
oSmtp.Send(oMailMsg)
oMailMsg = Nothing
End Sub
Regards
Stephan
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href=http:
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
i'm a beginner of C# any expert can help me ??
code as below !!
Sub On_Login(ByVal sender As Object, ByVal e As System.EventArgs) Handles user_pwd.TextChanged, send_btn.Click
Dim strSQL As String '存放SQL語法
Dim objConn As New System.Data.OleDb.OleDbConnection() '產生連結資料庫物件
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("./App_Data/member.mdb") '指定資料庫位置
objConn.Open() '開啟資料庫
strSQL = "Select * From 會員資料 where User_ID Like '" & user_id.Text & "' And user_PSD Like '" & user_pwd.Text & "'" '指定SQL語法
Dim objCmd As New System.Data.OleDb.OleDbCommand(strSQL, objConn) '執行SQL語法
Dim objReader As System.Data.OleDb.OleDbDataReader = objCmd.ExecuteReader() '接收結果
strSQL = "Insert Into log (User_ID, User_Time) Values ('" & user_id.Text & "','" & Now().ToString() & "')"
Dim insertCmd As New System.Data.OleDb.OleDbCommand(strSQL, objConn) '執行SQL語法
insertCmd.ExecuteNonQuery()
If objReader.Read() Then '搜尋成功 允許登入
If objReader.Item(9).ToString() = "管理者" Then
Session("user_id") = objReader.Item(1).ToString()
Session("role") = objReader.Item(9).ToString()
Response.Redirect("~/Administrator.aspx")
ElseIf objReader.Item(9).ToString() = "客服人員" Then
Session("user_id") = objReader.Item(1).ToString()
Session("role") = objReader.Item(9).ToString()
Response.Redirect("~/Attendant.aspx")
Else
Session("user_id") = objReader.Item(1).ToString()
Session("role") = objReader.Item(9).ToString()
Response.Redirect("~/Customer.aspx")
End If
Else '搜尋失敗
msg_label.Text = "帳號或密碼錯誤!!"
End If
objConn.Close() '關閉資料庫
End Sub
Bryan
|
|
|
|
|
Out Instant C# VB to C# converter produces:
//TODO: INSTANT C# TODO TASK: Insert the following converted event handlers at the end of the 'InitializeComponent' method for forms or into a constructor for other classes:
user_pwd.TextChanged += new System.EventHandler(On_Login);
send_btn.Click += new System.EventHandler(On_Login);
public void On_Login(object sender, System.EventArgs e)
{
string strSQL = null; //存放SQL語法
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(); //產生連結資料庫物件
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("./App_Data/member.mdb"); //指定資料庫位置
objConn.Open(); //開啟資料庫
strSQL = "Select * From 會員資料 where User_ID Like '" + user_id.Text + "' And user_PSD Like '" + user_pwd.Text + "'"; //指定SQL語法
System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand(strSQL, objConn); //執行SQL語法
System.Data.OleDb.OleDbDataReader objReader = objCmd.ExecuteReader(); //接收結果
strSQL = "Insert Into log (User_ID, User_Time) Values ('" + user_id.Text + "','" + System.DateTime.Now.ToString() + "')";
System.Data.OleDb.OleDbCommand insertCmd = new System.Data.OleDb.OleDbCommand(strSQL, objConn); //執行SQL語法
insertCmd.ExecuteNonQuery();
if (objReader.Read()) //搜尋成功 允許登入
{
if (objReader[9].ToString() == "管理者")
{
Session["user_id"] = objReader[1].ToString();
Session["role"] = objReader[9].ToString();
Response.Redirect("~/Administrator.aspx");
}
else if (objReader[9].ToString() == "客服人員")
{
Session["user_id"] = objReader[1].ToString();
Session["role"] = objReader[9].ToString();
Response.Redirect("~/Attendant.aspx");
}
else
{
Session["user_id"] = objReader[1].ToString();
Session["role"] = objReader[9].ToString();
Response.Redirect("~/Customer.aspx");
}
}
else //搜尋失敗
msg_label.Text = "帳號或密碼錯誤!!";
objConn.Close(); //關閉資料庫
}
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter
|
|
|
|
|
thank you very much for your help !!!
really thanks a lot !!!
Bryan
|
|
|
|
|
Sample Grid Image[^]
I'm looking to create the above sample using a datagridview. I'll be creating the grid at run-time and will have different time increaments for each grid. The row header with the (times) will be frozen and need to scroll with the grid. I'm thinking I'll need to us 2 grids side-by-side and link the scrolling events. But I'd like the forums input on it and if anyone has any differnet solutions. Thanks!
|
|
|
|
|
Can anybody help me? I am filling a datagrid with a file. one on the columns is currency (dollar and cents). I fcan convert the column to always create the cents (preferred) and the access DB shows ($1.00), but when I fill the datagrid is shows (1) and (7.93). I want to show ($1.00 and $7.93)
Thanks
silver-gray
|
|
|
|
|
FormatCurrency(columnVariable, 2)
FormatCurrency("1", 2) = $1.00
FormatCurrency("7.93", 2) = $7.93
|
|
|
|
|