M.Waqas Aslam 67 Posting Pro in Training Featured Poster

@ wasqas..waqas bro could you tell me why i get foreign kkey constraint error if i use this code under a button

Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(NewBookingDataSet.Customer)
Me.BookingBindingSource.EndEdit()
Me.BookingTableAdapter.Update(NewBookingDataSet.Booking)


same code works perfectly fine under binding navigator. i cant understand this problem.i use the above code to save the records for booking and customer..

foreign key constraint error is because your are deleting a record which is linked to you other table as a foreign key.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can simply do this like this

'Can only accept future dates(from today to the future, not the past)
if datetimepicker.value.date >= now.date() then
' if true then code here
else
'if false then here
end if

'Can only be AFTER departure date 
if datetimepicker.value.date > departuredate then
'true then code here
else
'false code here
end if 
'can only be in the past and NOT current 
if datetimepicker.value.date< now.date() then
' true coding here
else
'false coding here
end if

if anyone find it wrong , its better to notify me not to press down arrow.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello !
how are you all , hope all of you are in great state of health and peace , well i have some questions ,
1- WHAT IS MSSQL TRANSACTIONS .
2- where we use it.
3- Advantages /Disadvantages
4- Any imp information or point which you think it is imp to know about MSSQL TRANSACTIONS .

as i am not good in mssql so please use simple language :P , i have experience of working in mssql about 2 years , i know about , joins , pivot , functions , views , stored procedures ,but this mssql TRANSACTIONS term is new for me.

Waiting for your helpful comments .

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can use it under the button click .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please have a look at this , hope you will find something helpful .
http://msdn.microsoft.com/en-us/library/ms810613.aspx

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you can use replace option just replace the whole line with white space.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think this is your second thread you are posted for same question , please DO NOT ask any question more then once .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you have to use an Windows API for this.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you have to use simple head detail concept or you can call it master detail concept . now here is a sample layout of your master - detail or head- detail tables
head/master table
1- headid PK
2-orderdate
3-orderid-
4-customerid

detail table
1-detailid PK
2-headid FK
3-productid
4-qty
5-rate
6-total

now in your head table you can save the records which are not repeating in your orders , for example , your customer will be one in one order , your order id will be same , and in detail , you have so many products which are ordered by the customer , by using this style you can order more products at the same time. hope this will give you an idea .

Regards

Farhan_B commented: Great :) +3
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think it is better to take a datetime picker instead of label and then set the format property as custom , and set custom property as hh:mm then you will get the time like this 2:33 , now after this , just compare the time in your grid like this , and if it shows any error and not works then add :00 as string , as i showing you in my code . check this out

dim i as integer


for i = 0 to datagridview.rows.count-1
dim a as string 
a = datetimepicker.text & ":00"
if a = datagridview.item(6,i).value.tostring() and  now.date.tostring = datagridview.item(2,i).value.tostring()
    //place your email sending code here 
end if 

next

if you find any error in it , then please do tel me .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

at the top of your form , at very top of your form ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello i tested this code at my end and its working properly , please check this out

'import this .
import.system.form.application
'lets work with for-loop . now do this
dim buttonclick as boolean = false
dim i as integer

for i = 0 to 100 
while buttonclick= false
 doevents() 'it will let the computer works and you can perform any other action.
end while
next
 'and use this code at the button click

buttonclick = true

this will solve your prob , if your prob is solved then please mark this thread solved , and dont forget to vote me up :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

here is an idea sample code , not tested and not the best solution.

'lets take for loop . now do this
dim buttonclick as boolean = false
dim i as integer

for i = 0 to 100 
while buttonclick= false

end while
next
 'and use this code at the button click

buttonclick = true

may be this will solve your prob , but as i said this is not the ideal solution and i not tested it yet.so if it will show some prob then please dont mind.
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

you have to connect both laptops , one laptop have db server , and one has just your application , make users , and assign user roles , then just get the data of any kind inserted deleted , etc of specific user.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

can you please post the snap shoot of your form , and code behined it., and the error i think is that you are taking time of the day , its mean hh-mm-ss-ms , so it will not execute , until your condition is true , so i think you have to take hh-mm instead of time of day , may be this will solve your pron , other wise , if you post the form's snap shoot and code then i will try to provide you an working example.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i think you have to use proper coding to delete this record. here is an example . assume you have a table name bookings , fields of that tables are , bookingid , cutomerid ,location date , payment . now you want to delete records of a single customer. then do this

dim con as new sqlconnection("your connection string here")
dim cmd as new sqlcommand 
con.open()
cmd.connection= con
cmd.commandtext ="delete from bookings where customerid="& val(gridview.item(4,gridview.currentrow.index).value.tostring)
cmd.executenonquery()
con.close()

use this code at the double click event or single click event , or at a button click event , it will delete record of that customer , and for example if customer have more records and you want to just delete the single booking then change this line

cmd.commandtext ="delete from bookings where customerid="& val(gridview.item(4,gridview.currentrow.index).value.tostring) & " and bookingid="& val(gridview.item(0,gridview.currentrow.index).value.tostring)

and this will delete the single record of customer ,
as i said i dont know the structure of your db so it is an example , so please get an idea from it and complete you task :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok then used this ,hope this will solve your issue.

dim i as int 
dim total as decimal
for i=0 to datagrid.rows.count -1 
total = total + val(datagrid.item(4,i).value.tostring)' or you can use Cint
next
textboxTotal.text= total

try this .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please mark this thread solved , as you get the answer. so that others may find it helpful and they saved their time.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

if it is working then please mark this thread solved so that other people can also visit it for answer ..
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please be more specific , there is not that much time to read your all code , please tell me where you have prob and what you really want to do

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

can you please tell me , this listview is also at the same form where you are inserting some data in your db , if yes then just place the same code which you used to show values in your listview just after the code you are using to save data in you db . this will also perform same action , if you using timer control then you system will take load and always busy to check weather the records are update or not .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

crystal report , then just add group on your month , and then use summary to get total of your payment field , you can use summary option by using wizard and also you can get sum of all records of field payment by doing this , just right click at the detail of field and choose add summary and then a window will open , select the sum from the combo and other option according to your requirement and then press ok you will get the sum .

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please post your code , and also the snap shot of your form ,
regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

as adam_k said , it is better to use view or query to get sum of total payment. this is fast way to generate the reports, well you can also use group by and get sum of payment in your reporting tools , for example crystal reports , telerik reports etc. if you tell me about your reporting tools then it will be easy for me to guide you step by step to perform this action.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please be more specific about your requirement , explain your prob , in order to get good and quick solution.
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

to calculate the total payment use this code .

'for example you have a grid having column name payment .
'now use this code at the button click event

dim i as int 
dim total as decimal
for i=0 to datagrid.rows.count -1 
total = total + val(datagrid.item("payment",i).value.tostring)' or you can use Cint
next
textboxTotal.text= total

this code will calculate all the payments and show total in the textbox

Hope this will solved your prob.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

dilse4sk ,please explain your prob , so that i can better understand , please

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

i dont know what is the method to delete a thread , but you can mark this thread is solved , and just use first thread to get ans .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hye , is in this thread you are asking some new question , http://www.daniweb.com/software-development/vbnet/threads/417441 this is also your thread and you ask here same question , please do not post single question multiple time ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

is there is any error in it ? what is your prob please be more specific.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

as earlier i face the same prob with mssql server 2000 due to my connection string , so please also note this , i am using this connection string

Provider=SQLNCLI;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

hello!
i have shifted my application from mssql server 2000 to mssql server 2005 , now the prob is the command object is not returning the recordset if command text is stored procedure , here is my code please check it and guide me through errors .

dim cmdsp as command
dim rs as new ADODB.recordset
set cmdsp = new commadn 
cmdsp.activeconnection = cn
cmdsp.commandtext = "MyStoredProcedure"
cmdsp.commandtype = adcmdstoredproc


set rs= cmdsp.execute 'here i got an error the state of rs is zero , but if i used this code at mssql server 2000 then it will return the records.

please help me in this , and if you have some better code then please also post it here, i have even tried this also

rs.open "exec myprocedurename",myCon,adOpenStatic,AdLockReadOnly

but this code is also not working at my end ,please check it out as i need help very urgently ,

Best Regards

M.Waqas Aslam

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please change this code

'New DataSet 'New passer2012DataSet
        con.Open()
        da.Fill(ds, "employeeID")
        dt = ds.Tables(0)

        'databinding()
        cmbfirma.DataSource = ds 'Me.passer2012DataSet.Employees

with this

'New DataSet 'New passer2012DataSet
        con.Open()
ds.tables("employeeID").clear()
        da.Fill(ds, "employeeID")
        
        'databinding()
        cmbfirma.DataSource = ds.table("employeeID")

it will work fine :)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

your code will look like this . use this code at the click event of your list box.

listbox2.items.add(listbox1.selecteditem)

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , there is another way to do this , for example if you save record of a person save the date of that saving in db ,now at every time before saving it first check it whether the last date and the current date has the difference of 15 days if true then save it other wise give a msg . hope this will give you an idea.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well bernardz26! there are two simple ways to perform this , one is to declare a global or public variable and just access it at any part of your prog , and second way is to call the form then the call the control , here are both ways to perform this operation ,

'declare the public variable
public mynumber as int
 'now assign the value of first textbox of form1 to it .
'use this at the text change event of the textbox
mynumber = val(textbox6.text)
'now place this code at the your form two at any event where you want to sum both values of textbox6 of form1 and textbox6 of form2
textboxResult.text = val(textbox6.text)+mynumber
'this will show the result and sum both textbox values

now there is another way to perform same operation .

'use this code where you want to sum both values
textboxResult.text= val(form1.textbox6.text)+val(textbox6.text)

this will also perform same operation , hope this will solve your prob ,if your prob is solve then please dont forget to mark this thread solve ,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well i dont know what is the prob with this code but here is a code of insert .

dim con as new sqlconnection("connection string ")
dim cmd as new sqlcommand
con.open()
cmd.connection=con
cmd.commandtext="insert into table1 (id) values ("& txtid.text &")"
cmd.executenonquery()
con.close()

this will insert your records in your database , and there is no need to use dataadapter .

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well i am working in mssql , so i am writing this code for mssql , but u can change the sqldataadapter with oledbdataadapter etc , and if this code not solve your prob then it will surly give you an idea .

'code for department combo
dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataadapter("select departmentID,departmentname from dept",con)
dim dt as new datatable
da.fill(dt)
comboDepartment.datasource= dt
combodepartment.displaymember="departmentname"
combodepartment.Valuemember="departmentID"
con.close()

'code for year combo
dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataadapter("select yearID,year from YearTable",con)
dim dt as new datatable
da.fill(dt)
comboYear.datasource= dt
comboYear.displaymember="year"
comboYear.Valuemember="yearID"
con.close()

'code for class combo
dim con as new sqlconnection("connection string")
con.open()
dim da as new sqldataadapter("select ClassID,ClassName from Classes where yearID="&val( comboyear.selectedvalue) & " and departmentID="& val(combodepartment.selectedvalue),con)
dim dt as new datatable
da.fill(dt)
comboClass.datasource= dt
comboClass.displaymember="ClassName"
comboClass.valuemember="ClassID"
con.close
'NOTE:as i type all this here so may be there are some errors , so please dont mind if there is. 2nd thing if val(comboyear.selectedvalue) is not working properly then
'please use val(comboyear.selectedvalue.tostring()) and same with combodepartment.

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

simple put your save and delete code at the button click event.

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well answer of your first question is , you just add a button in toolstrip and set the background image or image property and select the image .it will set the image to the backgroud of your button
2-answer of your second question is use tabcontrols , select it from the tool box and add it to your form ,.
3-yes it is possible but you have to use the databse in order to perform this task with radio button and combobox , but there is an other method to perform this is to use conditional statement and predefine path of your pictures to your picture box.

Hope this will helps you

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok you can do like this

dim con as new sqlconnection("connection string")
dim cmd as new sqlcommand
con.open()
cmd.connection= con
cmd.commandtext="insert into table1 (field1) values ("& combobox1.text &")"
cmd.executenonquery()
con.close

you can use this code at any button click event to save the value of combo in db and also at selected index change event of your grid .
in place of text you can use the selectedvalue .tostring .
Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please you have to know two things , 1- after getting solved please mark the thread solved , 2- always start new thread for your new question . it is better to ask your question in new thread and mark this solved , also please also post your code in which you have a prob.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

well , simple you have to change the query like this

Dim da As New OleDb.OleDbDataAdapter("Select DISTINCT firm from Employees where firm='"& combobox1.text &"'", con)

use this , then your grid will only show the records of selected firm , now you have to use oledb connection in order to perform any db function , insertion , updation , delete , search , etc , so it is imp.

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please first you should know the difference between dataset and datatable , when ever you are using dataset then please define a table in it , like this

dim ds2 as new dataset
ds2.table("table").clear()
'now after this fill dataset like this 
DataAdapter1.fill(ds2,"table")
'now assign the data source to the grid
DataGridView1.datasource = ds2.table("table")

this will work fine , in single dataset there can be one or more then one tables . so when ever you are using single table then there is no need to use dataset , use datatable .

Best Regards

poolet25 commented: Perfect!!!! +1
M.Waqas Aslam 67 Posting Pro in Training Featured Poster
kingsonprisonic commented: good link... +5
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

it is very basic thing that your phone should connect to your pc in any way , you can use bluetooth , or some cable for this.

jbennet commented: how was "You can buy phone recording devices from electronic stores like Maplin" making fun of anyone? -3
M.Waqas Aslam 67 Posting Pro in Training Featured Poster

for this declare a public variable , like this

public Name as string 
'now place this code at the selected index change event
name = combo.text

now you can get name variable value at any place in your form,

Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

ok , first we have to show values in grid

dim con as new sqlconnection("connectionstring")
con.open()
dim da as new sqldataadapter("select id,name from table",con)
dim dt as new datatable
da.fill(dt)
datagrid.datasource = dt 
con.close

now above code will show records id and name from table table , so now we have to update the records from the grid after making change , do like this

for i = 0 to datagrid.rows.count-1 
dim con as new sqlconnection("connectionstring")
con.open()
dim i as integer
dim cmd as new sqlcommand 
cmd.commandtext = "update table set name='"& datagrid.item(1,i).value.tostring &" where id=" val(datagrid.item(0,i).values.tostring)
cmd.connection = con
cmd.executenonquery() 
con.close
next

this will update field name , note: as i type all this code here , so may be there are some spelling mistakes , please do not copy paste , first understand the code then start writing , without efforts there is no learning ,

Best Regards

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

please show your code , so that i can check it ,

M.Waqas Aslam 67 Posting Pro in Training Featured Poster

what you had done so for ?? , please show some efforts then we will help you in this.

Begginnerdev commented: You shouldn't be voted down for stating a fact. Therefore, I voted you back up. +5