473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

insert buton

111 100+
hii all,

im trying to work on insert button, when i give details if already the manager is available in that project, it shd display a message.. or else it shd insert...

insert_button click:>>>>[vb.net]


Dim cnSQL As MySqlConnection
Dim cmSQL As MySqlCommand
Dim drSQL As MySqlDataReader


Dim objListItem As ListItem

objListItem = CType(cbProjectName.SelectedItem, ListItem)



If cbProjectName.SelectedItem Is objListItem And cbCategoriesName.SelectedItem Is objListItem Then



Dim cmSQL As New MySqlCommand

Dim myselectquery As String = "SELECT sta_category_id_fk FROM tbl_staff_assignments WHERE " _
& "tbl_staff_assignments.sta_project_id_fk =(SELECT pr_project_id_pk FROM tbl_projects " _
& "WHERE tbl_projects.pr_project_location = ?PName ) tbl_projects.pr_project_id_pk = ?CID "


cmSQL.Parameters.Add("?PName", objListItem.ToString)
cmSQL.Parameters.Add("?CID", 1)

cnSQL = New MySqlConnection
cnSQL.ConnectionString = connect.ConnectionString

cmSQL.Connection = cnSQL
cmSQL.CommandText = myselectquery

Try
cnSQL.Open()
drSQL = cmSQL.ExecuteReader()

If drSQL.HasRows = True Then

While drSQL.Read

If drSQL.Item("sta_category_id_fk ") = "?CID" Then

MsgBox("Manager available in this project.. select other project or insert new project")


Else

insert staff.. code



thnx n need help..
Jul 12 '07 #1
4 1069
shweta123
692 Expert 512MB
Hi,

Where exactly you are stuck ? Are you getting any error?
Jul 12 '07 #2
rhepsi
111 100+
Hi,

Where exactly you are stuck ? Are you getting any error?

Hii,

im not getting any error but the records are not been inserted nor it showing any error message that manager is already available...

can u please help me with the code....

thnx...
Jul 13 '07 #3
shweta123
692 Expert 512MB
Hi,

Can try your code in different way?

You can take the Pname and CID as variables instaed of adding the parameters?

e.g.


Dim com As New OleDbCommand

Dim myselectquery As String = "SELECT sta_category_id_fk FROM tbl_staff_assignments WHERE " _
& "tbl_staff_assignments.sta_project_id_fk =(SELECT pr_project_id_pk FROM tbl_projects " _
& "WHERE tbl_projects.pr_project_location = " & PName & ") tbl_projects.pr_project_id_pk = & CID & " "

Dim sta_category_id_fkas integer
sta_category_id_fk = com.ExecuteScalar()


If sta_category_id_fk = CID Then
MsgBox("Manager available in this project.. select other project or insert new project")
Else
''''''''''''''Insert statement
End if
Jul 13 '07 #4
rhepsi
111 100+
Hi,

Can try your code in different way?

You can take the Pname and CID as variables instaed of adding the parameters?

e.g.


Dim com As New OleDbCommand

Dim myselectquery As String = "SELECT sta_category_id_fk FROM tbl_staff_assignments WHERE " _
& "tbl_staff_assignments.sta_project_id_fk =(SELECT pr_project_id_pk FROM tbl_projects " _
& "WHERE tbl_projects.pr_project_location = " & PName & ") tbl_projects.pr_project_id_pk = & CID & " "

Dim sta_category_id_fkas integer
sta_category_id_fk = com.ExecuteScalar()


If sta_category_id_fk = CID Then
MsgBox("Manager available in this project.. select other project or insert new project")
Else
''''''''''''''Insert statement
End if



hii, thnx for ur reply...
when i tried like this:
im getting an error stating as:

"Only BYTE ARRAYS AND STINGS CAN BE SERIALIZED BY MYSQLBINARY"

CAN U HELP Me...

thnx..
hepsi..
Jul 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vincent M. | last post by:
Hello, Is there any way to change the result of the IE navigation back buton ? Something like that: history.back() = "index.html" ; Thanks, Vincent.
3
by: Howard Hinnant | last post by:
I recently asked for a survey of multimap insert with hint behavior, in support of a paper I'm writing concerning lwg issue 233. My sincere thanks to Beman Dawes, Raoul Gough, Russell Hind, Bronek...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
3
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The...
2
by: Eng Teng | last post by:
Where is the part to set when my mouse pointer move to textbox or label or buton it will display text description ? Regards, Tee
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.