.ExternalClass .EC_hmmessage P
i've added new item called service- based database. after that, i've created doctor table, course table, exam table, and an empty table called exam_report to allow program selects randomly from the other tables.
how it works: first the user will get a form with many buttons: courses, doctors, exams, and exam report. second if the user click over exam report, a new form will appear with many columns. this form should has exam course - exam day - exam time - 3 doctors name who will observe the students.
behind code: the doctors shouldn't be the instructors of the course - the doctor has no appoinment in this day - the doctor has no hloiday and so on..
okay my code is the following :
____________________________________________________________________________ Public Class Form6 Dim j, a As Integer Dim d, f, h As Integer Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ta_ExamReport As Database1DataSet1TableAdapters.exam_reportTableAdapter
Dim ta_All_Courses As Database1DataSet1TableAdapters.courseTableAdapter = New Database1DataSet1TableAdapters.courseTableAdapter Dim All_Courses As Database1DataSet1.courseDataTable = New Database1DataSet1.courseDataTable ta_All_Courses.Fill(All_Courses)
Dim ta_All_Doctors As Database1DataSet1TableAdapters.doctorTableAdapter = New Database1DataSet1TableAdapters.doctorTableAdapter Dim All_Doctors As Database1DataSet1.doctorDataTable = New Database1DataSet1.doctorDataTable ta_All_Doctors.Fill(All_Doctors)
Dim ta_All_Exams As Database1DataSet1TableAdapters.examTableAdapter = New Database1DataSet1TableAdapters.examTableAdapter Dim All_Exams As Database1DataSet1.examDataTable = New Database1DataSet1.examDataTable ta_All_Exams.Fill(All_Exams)
d = 0 f = 0 h = 0
ta_ExamReport = New Database1DataSet1TableAdapters.exam_reportTableAdapter
Dim check3times As Integer = 3 For Me.a = 0 To All_Exams.Rows.Count() - 1 For Me.j = 0 To All_Doctors.Rows.Count() - 1
If (All_Doctors(j)("InvigNum") > 0 And All_Doctors(j)("DRID") <> All_Exams(a)("DRID") And All_Doctors(j)("holidays") <> All_Exams(a)("EXday") And All_Doctors(j)("appt_days") <> All_Exams(a)("EXday")) Then
If (h = 1 And f = 1 And d = 0) Then ta_ExamReport.UpdateOncall(All_Doctors(j)("Dname")) All_Doctors(j)("InvigNum") = ta_All_Doctors.UpdateInvigNumAuto() d = 1 End If If (h = 1 And f = 0 And d = 0) Then All_Doctors(j)("InvigNum") = ta_All_Doctors.UpdateInvigNumAuto() ta_ExamReport.UpdateInvig2(All_Doctors(j)("Dname")) f = 1 End If If (h = 0 And f = 0 And d = 0) Then ta_ExamReport.InsertIntoExamReport(All_Exams(a)("EXday"), All_Exams(a)("CID"), All_Doctors(j)("Dname"), All_Doctors(j)("Dname"), All_Doctors(j)("Dname")) All_Doctors(j)("InvigNum") = ta_All_Doctors.UpdateInvigNumAuto() h = 1 End If If (h = 1 And f = 1 And d = 1) Then h = 0 d = 0 f = 0 End If End If j = j + 1 Next a = a + 1 Next
End Sub __________________________________________
now, this is free from errors, but it didn't get inside the big if statement >...... WHY??
An expert who has achieved level 3 by getting 1000 points
An expert that got 10 achievements.
An expert that got 5 achievements.
An expert whose answer got voted for 100 times.
Re: inserting records into sql server using VB
It didn't enter the big if statement because all of the conditions to enter the loop were not met. You will need to set a breakpoint on the If statement and look at the values to find out why it falls short of the criteria.
Also, instead of incrementing the loop variables immediately before the Next statement, you could simply include a Step 2 modifier in the For statement to check every other row in the tables. You should not manually modify a counter in a For loop. You have class-level variables that appear to be used only inside of a Sub (that is where they should be declared unless they are used in another function in the class). You should be giving variables meaningful names and types. The variables d, h, and f are declared as integers, but treated as booleans and their names give no idication of their use in the code. And last (for now), the check3times varialbe is declared but never used.
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need. goodluck!
- If you need clarification, ask it in the comment box above.
- Better answers use proper spelling and grammar.
- Provide details, support with references or personal experience.
Tell us some more! Your answer needs to include more details to help people.You can't post answers that contain an email address.Please enter a valid email address.The email address entered is already associated to an account.Login to postPlease use English characters only.
Tip: The max point reward for answering a question is 15.
Detach you database. Overwrite the mdf and ldf files you've restored from your backup with your files from the D: drive. Reattach the database.
There is no guarantee that this will work or if it works, that your database is in a state where you can continue to work with.
If that doesn't work then there is an option to try to restore database using SQL Server Recovery Toolbox. It is a powerful tool for data recovery. They have a demo version. So you can check it works in your situation or not. http://www.oemailrecovery.com/sql_repair.html
I would like to suggest you to use of MDF Repair Kit. An exciting new product from Repair Kit, this MS SQL MDF repair tool is an absolutely indispensable tool for anyone who wants to know how to repair MDF files in minutes. The program is based on a powerful analysis core and uses a convenient wizard-driven UI.
Create an appropriately named database on the target machine
Load the file using the mysql command:
$ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
Have a look how you can restore your tut_backup.sql file to the Tutorials database.
$ mysql -u root -p Tutorials < tut_backup.sql
To restore compressed backup files you can do the following:
gunzip < [backupfile.sql.gz] ' mysql -u [uname] -p[pass] [dbname]
If you need to restore a database that already exists, you'll need to use mysqlimport
command. The syntax for mysqlimport is as follows:
mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]
'declare the SQL statement that will query the database SQL = "SELECT * FROM TABLE_NAME"
'create an instance of the ADO connection and recordset objects Set Connection = Server.CreateObject("ADODB.Connection") Set Recordset = Server.CreateObject("ADODB.Recordset") 'Open the connection to the database Connection.Open ConnString
'Open the recordset object executing the SQL statement and return records Recordset.Open SQL,Connection
'first of all determine whether there are any records If Recordset.EOF Then Response.Write("No records returned.") Else 'if there are records then loop through the fields Do While NOT Recordset.Eof Response.write Recordset("FIRST_FIELD_NAME") Response.write Recordset("SECOND_FIELD_NAME") Response.write Recordset("THIRD_FIELD_NAME") Response.write "<br>" Recordset.MoveNext Loop End If
'close the connection and recordset objects to free up resources Recordset.Close Set Recordset=nothing Connection.Close Set Connection=nothing
You must create an ODBC connection to your SQL database in the Windows Control Panel. Than you can call your ODBC connection via Visual Studio 2005. You can also create a DSN in Visual Studio 2005 and reference in that way. You will not be able to connect to an MDF but instead you have to connect to the SQL Server Service. Of course the username you use to connect must have access that will be created on the SQL server.
I suggest you use the Enterprise manager (gui tool to manage SQL).
Restoring a single table is not an option.
You can however restore a file or filegroup.
Make sure to backup before you start and NOT to restore database to its original name or original file location, to avoid acidents.
Normally you will have databases with only 2 files: the data at its Primary file group, and log file.
You may wish to create a new file group and move tables to the new group by recreating them there and exporting data from old table to new table. Then recreate indexes. This may prove to be complex as all tables and indexes have unique names and can't coexist with exact duplicate of them.
oh yea..... did I say backup?
well just in case backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup backup
but dont overwrite that backup
An easy way to transfer objects (tables, user defined functions, stored procedures, etc.) is to use Enterprise Manager's "Generate SQL" feature. Use this process at your own risk. Doing it wrong could mess up your existing database.
1. In Enterprise Manager, right-click on the old database and choose "All Tasks" then "Generate SQL Script". 2. In the dialog that comes up, click "Show All" then select the checkboxes for "all stored procedures" and "all user defined functions". (You might also want to check some other boxes, depending on your exact situation.) 3. Click the "generate" button and save the script that it creates. 4. Run the script in the NEW database.
If you run the script in your OLD database, it may destroy your objects, and that would be very bad. Make sure you run the script in your NEW database. (While we're on this subject, it's a good time to mention that you should back up your database before you start this process, and you should make changes to a test system before migrating it to production.)
That should move your stored procedures and user defined functions over.
You can use a similar process to move tables, views, users, and other objects over as well.
Generally database updates either require a commit to have the database perform the appropriate checking and actually flag the rows as part of the database. That Commit can occur in two ways -- some databases can be setup with an auto commit or auto rollback when the database is disconnected. The first means the programmer needs to do nothing. The second means if the programmer does not commit the updates are backed out of the database. To commit is generally considered bad because if there are any data errors partial transactions and logically inconsistent contents can exist in a database. For example entering an order for merchandise requires a single header row to identify the customer and multiple items rows to indicate what was ordered. If the third item record added to an order had an error and the application did not rollback and the database auto committed and incomplete order with only two items would be saved in the database. Traditionally databases with an automatic action at shutdown are set to rollback to assure such partial information is not saved. Even with auto rollback good programs detect errors and rollback themselves and allow users to continue.
The net result of the above is the probability that if the inserts actually occurred as you believe the there was a missing commit to confirm their addition to the database. and an automated rollback kept them from being completely added to the database. Another alternative is that the insert was not error checked in the program code and it failed meaning despite the program counter claiming rows were inserted in fact they were not.